Computation
openFile file mode allocates and returns a
new, open handle to manage the file
file. It manages input if
mode is
ReadMode, output if
mode is
WriteMode or
AppendMode, and both input and output if
mode is
ReadWriteMode.
If the file does not exist and it is opened for output, it should be
created as a new file. If
mode is
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
openFile with
mode
WriteMode unless it is subsequently written to successfully.
The handle is positioned at the end of the file if
mode is
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:
On POSIX systems,
openFile is an
interruptible operation
as described in
Control.Exception.
Note: if you will be working with files containing binary data, you'll
want to be using
openBinaryFile.