mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 10:32:56 +01:00
#4170: Poco::FileStream is always opened with std::ios::in | std::ios::out
This commit is contained in:
@@ -60,6 +60,14 @@ public:
|
|||||||
/// does not exist or is not accessible for other reasons and
|
/// does not exist or is not accessible for other reasons and
|
||||||
/// a new file cannot be created.
|
/// a new file cannot be created.
|
||||||
|
|
||||||
|
void open(const std::string& path);
|
||||||
|
/// Opens the file specified by path, using the default mode given
|
||||||
|
/// in the constructor.
|
||||||
|
///
|
||||||
|
/// Throws a FileException (or a similar exception) if the file
|
||||||
|
/// does not exist or is not accessible for other reasons and
|
||||||
|
/// a new file cannot be created.
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
/// Closes the file stream.
|
/// Closes the file stream.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -39,7 +39,14 @@ FileIOS::~FileIOS()
|
|||||||
void FileIOS::open(const std::string& path, std::ios::openmode mode)
|
void FileIOS::open(const std::string& path, std::ios::openmode mode)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
_buf.open(path, mode | _defaultMode);
|
_buf.open(path, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FileIOS::open(const std::string& path)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
_buf.open(path, _defaultMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -66,10 +73,10 @@ FileInputStream::FileInputStream():
|
|||||||
|
|
||||||
|
|
||||||
FileInputStream::FileInputStream(const std::string& path, std::ios::openmode mode):
|
FileInputStream::FileInputStream(const std::string& path, std::ios::openmode mode):
|
||||||
FileIOS(std::ios::in),
|
FileIOS(mode | std::ios::in),
|
||||||
std::istream(&_buf)
|
std::istream(&_buf)
|
||||||
{
|
{
|
||||||
open(path, mode);
|
open(path, mode | std::ios::in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -86,10 +93,10 @@ FileOutputStream::FileOutputStream():
|
|||||||
|
|
||||||
|
|
||||||
FileOutputStream::FileOutputStream(const std::string& path, std::ios::openmode mode):
|
FileOutputStream::FileOutputStream(const std::string& path, std::ios::openmode mode):
|
||||||
FileIOS(std::ios::out),
|
FileIOS(mode | std::ios::out),
|
||||||
std::ostream(&_buf)
|
std::ostream(&_buf)
|
||||||
{
|
{
|
||||||
open(path, mode);
|
open(path, mode | std::ios::out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -106,7 +113,7 @@ FileStream::FileStream():
|
|||||||
|
|
||||||
|
|
||||||
FileStream::FileStream(const std::string& path, std::ios::openmode mode):
|
FileStream::FileStream(const std::string& path, std::ios::openmode mode):
|
||||||
FileIOS(std::ios::in | std::ios::out),
|
FileIOS(mode),
|
||||||
std::iostream(&_buf)
|
std::iostream(&_buf)
|
||||||
{
|
{
|
||||||
open(path, mode);
|
open(path, mode);
|
||||||
|
|||||||
Reference in New Issue
Block a user