Commit e65ac0b2 breaks existing behaviour of FileInputStream on macOS

@ed95 The recent commit e65ac0b2 adds the O_CREAT flag to the open call in FileInputStream::openHandle(). This breaks existing behaviour on macOS (didn’t check other platforms). Minimal example:

juce::String path ("/doesnotexist.png");
juce::File file (path);
juce::FileInputStream stream (file);

CHECK_FALSE (stream.openedOk());

Previously, creating the stream would fail. Since this commit, the call to stream ctor will actually create a file on disk. Which breaks the above unit test (and probably the behaviour of some projects built with JUCE).

Is this intentional? If yes, what is the recommended way to get the old behaviour back (i.e. creating a FileInputStream but without creating a new file if the file does not exist)?

Should the users work around this in client code by adding a check for if (! file.existsAsFile()) before creating a FileInputStream ?

Or is this unintentional and should be fixed in JUCE itself?

Thanks much!
Timur

1 Like

No, this wasn’t an intentional change. Commit 330df2b should revert this back to the previous behaviour (as well as squashing the warnings that the original commit was trying to get rid of). Thanks for the heads up!

Thanks!