# Commit e65ac0b2 breaks existing behaviour of FileInputStream on macOS

**URL:** <https://forum.juce.com/t/commit-e65ac0b2-breaks-existing-behaviour-of-fileinputstream-on-macos/38059>\
**Category:** General JUCE discussion\
**Created:** [March 12, 2020, 10:10pm UTC](https://forum.juce.com/t/commit-e65ac0b2-breaks-existing-behaviour-of-fileinputstream-on-macos/38059 "2020-03-12T22:10:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![timur](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/timur/32/541_2.png) [@timur](https://forum.juce.com/u/timur)\
**Post date:** [March 12, 2020, 10:10pm UTC](https://forum.juce.com/t/commit-e65ac0b2-breaks-existing-behaviour-of-fileinputstream-on-macos/38059/1 "2020-03-12T22:10:36Z")

</div>

@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:

```auto
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

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [March 16, 2020, 11:44am UTC](https://forum.juce.com/t/commit-e65ac0b2-breaks-existing-behaviour-of-fileinputstream-on-macos/38059/2 "2020-03-16T11:44:18Z")

</div>

No, this wasn’t an intentional change. Commit [330df2b](https://github.com/WeAreROLI/JUCE/commit/330df2b3e67159b4fa6d4f27b20af5dfc56d5851) 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!

---

<div class="post-metadata">

**Author:** ![timur](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/timur/32/541_2.png) [@timur](https://forum.juce.com/u/timur)\
**Post date:** [March 17, 2020, 1:20am UTC](https://forum.juce.com/t/commit-e65ac0b2-breaks-existing-behaviour-of-fileinputstream-on-macos/38059/3 "2020-03-17T01:20:27Z")

</div>

Thanks!
