Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poco::FileStream is always opened with std::ios::in | std::ios::out #4170

Closed
obiltschnig opened this issue Sep 30, 2023 · 1 comment
Closed
Assignees

Comments

@obiltschnig
Copy link
Member

It's not possible to open a Poco::FileStream with std::ios::in flags only, as the constructor always applies std::ios::in | std::ios::out. This can be an issue when opening files that are not writable.

@Mike4Online
Copy link

I had some code that broke on Windows and macOS between Poco 1.12.5p2 and 1.13.3 which did the following:

Poco::FileStream myFileStream;
myFileStream.open(myOutputFilePath, std::ios::binary);

The above code throws a Poco::FileNotFoundException when attempting to create the file specified by myOutputFilePath.

The following code change corrects this for Poco 1.13.X:

Poco::FileStream myFileStream(myOutputFilePath, std::ios::out);

The changes to the openmode defaults and the failure of specifying std::ios::binary should be listed as one of the breaking changes in the Poco 1.13.0 release notes (among the other breaking changes).

The FileStream documentation still shows a constructor which defaults to an openmode of std::ios::out | std::ios::in --

FileStream(
const std::string & path,
std::ios::openmode mode = std::ios::out | std::ios::in
);

It seems this openmode default value is no longer this way since this issue (#4170) was resolved. if that is the case the documentation for FileStream should be revised accordingly.

The Description in the FileStream documentation still says that binary mode is always enabled even if not specified. I assume that still applies to FileStream in Poco 1.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants