Handle operations implemented by file descriptors (FDs)
- stdin :: Handle
- stdout :: Handle
- stderr :: Handle
- openFile :: FilePath -> IOMode -> IO Handle
- openBinaryFile :: FilePath -> IOMode -> IO Handle
- openFileBlocking :: FilePath -> IOMode -> IO Handle
- mkHandleFromFD :: FD -> IODeviceType -> FilePath -> IOMode -> Bool -> Maybe TextEncoding -> IO Handle
- fdToHandle :: FD -> IO Handle
- fdToHandle' :: CInt -> Maybe IODeviceType -> Bool -> FilePath -> IOMode -> Bool -> IO Handle
- isEOF :: IO Bool
file mode allocates and returns a new, open
handle to manage the file
file. It manages input if
ReadMode, output if
and both input and output if mode is
If the file does not exist and it is opened for output, it should be
created as a new file. If
WriteMode and the file
already exists, then it should be truncated to zero length.
Some operating systems delete empty files, so there is no guarantee
that the file will exist following an
WriteMode unless it is subsequently written to successfully.
The handle is positioned at the end of the file if
AppendMode, and otherwise at the beginning (in which case its
internal position is 0).
The initial buffer mode is implementation-dependent.
This operation may fail with:
isAlreadyInUseErrorif the file is already open and cannot be reopened;
isDoesNotExistErrorif the file does not exist; or
isPermissionErrorif the user does not have permission to open the file.
Note: if you will be working with files containing binary data, you'll want to
openFile, but open the file in binary mode.
On Windows, reading a file in text mode (which is the default)
will translate CRLF to LF, and writing will translate LF to CRLF.
This is usually what you want with text files. With binary files
this is undesirable; also, as usual under Microsoft operating systems,
text mode treats control-Z as EOF. Binary mode turns off all special
treatment of end-of-line and end-of-file characters.
openFile, but opens the file in ordinary blocking mode.
This can be useful for opening a FIFO for reading: if we open in
non-blocking mode then the open will fail if there are no writers,
whereas a blocking open will block until a writer appears.
Turn an existing file descriptor into a Handle. This is used by various external libraries to make Handles.
Makes a binary Handle. This is for historical reasons; it should probably be a text Handle with the default encoding and newline translation instead.
Old API kept to avoid breaking clients