It's not very well documented, because O_CREAT is not passed like the other flags via OpenFileFlags, but implicitly via Maybe FileMode.
The manpage says that
If O_EXCL is set and O_CREAT is not set, the result is undefined.
This library should either make the correspondence of those input arguments clear or make it impossible to use the combination. The following would already be quite an improvement:
-- |Correspond to some of the int flags from C's fcntl.h.
data OpenFileFlags =
OpenFileFlags {
append :: Bool, -- ^ O_APPEND
exclusive :: Bool, -- ^ O_EXCL, result is undefined if O_CREAT is False
noctty :: Bool, -- ^ O_NOCTTY
nonBlock :: Bool, -- ^ O_NONBLOCK
trunc :: Bool, -- ^ O_TRUNC
creat :: Maybe FileMode -- ^ O_CREAT
}
And then remove the extraneous Maybe FileMode arguments from open_.
It's not very well documented, because
O_CREATis not passed like the other flags viaOpenFileFlags, but implicitly viaMaybe FileMode.The manpage says that
This library should either make the correspondence of those input arguments clear or make it impossible to use the combination. The following would already be quite an improvement:
And then remove the extraneous
Maybe FileModearguments fromopen_.