The mode of a file handle (i.e., a set of open
flags and an fdopen
mode).
All modes do not translate line endings (i.e., O_BINARY
on Windows) and
are not inherited across process creation (i.e., O_NOINHERIT
on Windows,
O_CLOEXEC
elsewhere).
References:
Constructors
-
read : IO.FS.Mode
File opened for reading. On open, the stream is positioned at the beginning of the file. Errors if the file does not exist.
-
open
flags:O_RDONLY
-
fdopen
mode:r
-
-
write : IO.FS.Mode
File opened for writing. On open, truncate an existing file to zero length or create a new file. The stream is positioned at the beginning of the file.
-
open
flags:O_WRONLY | O_CREAT | O_TRUNC
-
fdopen
mode:w
-
-
writeNew : IO.FS.Mode
New file opened for writing. On open, create a new file with the stream positioned at the start. Errors if the file already exists.
-
open
flags:O_WRONLY | O_CREAT | O_TRUNC | O_EXCL
-
fdopen
mode:w
-
-
readWrite : IO.FS.Mode
File opened for reading and writing. On open, the stream is positioned at the beginning of the file. Errors if the file does not exist.
-
open
flags:O_RDWR
-
fdopen
mode:r+
-
-
append : IO.FS.Mode
File opened for writing. On open, create a new file if it does not exist. The stream is positioned at the end of the file.
-
open
flags:O_WRONLY | O_CREAT | O_APPEND
-
fdopen
mode:a
-