Moduleunix-2.8.7.0Haskell2010
System.Posix.IO.ByteString
POSIX IO support. These types and functions correspond to the unix functions open(2), close(2), etc. For more portable functions which are more like fopen(3) and friends from stdio.h, see System.IO.
- 5 types
- 24 values
- Packageunix-2.8.7.0
- Exports29
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceByteString.hsc
Input / Output
0 declarationsStandard file descriptors
Opening and closing files
Correspond to some of the int flags from C's fcntl.h.
Constructors
Instances4Eq, Ord, Read, Show
Eq OpenFileFlagsDefined in unix-2.8.7.0 · System.Posix.IO.CommonOrd OpenFileFlagsDefined in unix-2.8.7.0 · System.Posix.IO.CommonRead OpenFileFlagsDefined in unix-2.8.7.0 · System.Posix.IO.CommonShow OpenFileFlagsDefined in unix-2.8.7.0 · System.Posix.IO.Common
Default values for the OpenFileFlags type.
Each field of OpenFileFlags is either False or Nothing respectively.
Open and optionally create this file. See System.Posix.Files
for information on how to use the FileMode type.
openFdAt :: Maybe FdOptional directory file descriptor
-> RawFilePathPathname to open
-> OpenModeRead-only, read-write or write-only
-> OpenFileFlagsAppend, exclusive, truncate, etc.
-> IO Fd
Open a file relative to an optional directory file descriptor.
Directory file descriptors can be used to avoid some race conditions when navigating changing directory trees, or to retain access to a portion of the directory tree that would otherwise become inaccessible after dropping privileges.
createFileAt Create and open a file for write-only, with default flags, relative an optional directory file-descriptor.
Directory file descriptors can be used to avoid some race conditions when navigating changing directory trees, or to retain access to a portion of the directory tree that would otherwise become inaccessible after dropping privileges.
Close this file descriptor. May throw an exception if this is an invalid descriptor.
Reading/writing data
Programmers using the fdRead and fdWrite API should be aware that EAGAIN exceptions may occur for non-blocking IO!
Read data from an Fd and return it as a ByteString. Throws an exception if this is an invalid descriptor, or EOF has been reached.
Write a ByteString to an Fd.
fdReadBuf Read data from an Fd into memory. This is exactly equivalent
to the POSIX read function.
fdWriteBuf Write data from memory to an Fd. This is exactly equivalent
to the POSIX write function.
Seeking
May throw an exception if this is an invalid descriptor.
File options
Constructors
AppendOnWriteO_APPEND
CloseOnExecFD_CLOEXEC
NonBlockingReadO_NONBLOCK
SynchronousWritesO_SYNC
May throw an exception if this is an invalid descriptor.
May throw an exception if this is an invalid descriptor.
Locking
May throw an exception if this is an invalid descriptor.
May throw an exception if this is an invalid descriptor.
May throw an exception if this is an invalid descriptor.
Pipes
The createPipe function creates a pair of connected file descriptors. The first component is the fd to read from, the second is the write end. Although pipes may be bidirectional, this behaviour is not portable and programmers should use two separate pipes for this purpose. May throw an exception if this is an invalid descriptor.
Duplicating file descriptors
May throw an exception if this is an invalid descriptor.
May throw an exception if this is an invalid descriptor.
Converting file descriptors to/from Handles
Extracts the Fd from a Handle. This function has the side effect of closing the Handle (and flushing its write buffer, if necessary), without closing the underlying Fd.
Warning: This means you take over ownership of the underlying Fd.
hClose on the Handle will no longer have any effect.
This will break common patterns to avoid file descriptor leaks,
such as using hClose in the cleanup action of Control.Exception.bracket,
making it a silent no-op.
Be sure to close the returned Fd yourself to not leak it.