![]() | Library Documentation | Structures | Signatures | Identifiers | Packages | About |
POSIX_IO (basis)Posix IO operations.
The structure Posix.IO specifies functions that provide the primitive POSIX input/output operations, as described in Section 6 of the POSIX standard 1003.1,1996.signature POSIX_IO =
sig
eqtype file_desc
eqtype pid
datatype whence =
SEEK_SET
| SEEK_CUR
| SEEK_END
datatype open_mode =
O_RDONLY
| O_WRONLY
| O_RDWR
structure FD :
sig
include BIT_FLAGS
val cloexec : flags
end
structure O :
sig
include BIT_FLAGS
val append : flags
val nonblock : flags
val sync : flags
end
val close : file_desc -> unit
val dup : file_desc -> file_desc
val dup2 : {old : file_desc, new : file_desc} -> unit
val dupfd : {old : file_desc, base : file_desc} -> file_desc
val pipe : unit -> {infd : file_desc, outfd : file_desc}
val getfd : file_desc -> FD.flags
val setfd : file_desc * FD.flags -> unit
datatype lock_type
= F_RDLCK
| F_WRLCK
| F_UNLCK
val setfl : file_desc * O.flags -> unit
val getfl : file_desc -> O.flags * open_mode
val lseek : file_desc * Position.int * whence -> Position.int
val readVec : file_desc * int -> Word8Vector.vector
val readArr : file_desc * Word8ArraySlice.slice -> int
val writeVec : file_desc * Word8VectorSlice.slice -> int
val writeArr : file_desc * Word8ArraySlice.slice -> int
val mkTextReader : { fd : file_desc,
name : string,
initBlkMode : bool
} -> TextPrimIO.reader
val mkTextWriter : { fd : file_desc,
name : string,
appendMode : bool,
initBlkMode : bool,
chunkSize : int
} -> TextPrimIO.writer
val mkBinReader : { fd : file_desc,
name : string,
initBlkMode : bool
} -> BinPrimIO.reader
val mkBinWriter : { fd : file_desc,
name : string,
appendMode : bool,
initBlkMode : bool,
chunkSize : int
} -> BinPrimIO.writer
end
[cloexec] File descriptor flag that, if set, will cause the file
descriptor to be closed should the opening process replace itself
(through exec, etc.). If cloexec is not set, the open file
descriptor will be inherited by the new process.
[append] File status flag which forces the file offset to be set
to the end of the file prior to each write.
[nonblock] File status flag used to enable non-blocking I/O.
[sync] File status flag enabling writes using ``synchronized I/O
file integrity completion.''
O_RDONLY : Open a file for reading only.
O_WRONLY : Open a file for writing only.
O_RDWR : Open a file for reading and writing.
[type flock] Type representing an advisory lock. It can be
considered an abstraction of the record used as the argument to
the flock function below.
[flock {ltype, whence, start, len, pid}] creates a flock value
described by the parameters. The whence and start parameters give
the beginning file position as in lseek. The len value provides
the number of bytes to be locked. If the section starts at the
beginning of the file and len = 0, then the entire file is
locked. Normally, pid will be NONE. This value is only used in a
flock returned by getlk.
[ltype flock]
[whence flock]
[start flock]
[len flock]
[pid flock]
These are projection functions for the fields composing a flock
value.
fd : A file descriptor for a file opened for reading.
name : The name associated with the file, used in error
messages shown to the user.
initBlkMode : False if the file is currently in non-blocking mode,
i.e., if the flag O.nonblock is set in #1(getfl fd).
fd : A file descriptor for a file opened for writing.
name : The name associated with the file, used in error
messages shown to the user.
initBlkMode : False if the file is currently in non-blocking mode,
i.e., if the flag O.nonblock is set in #1(getfl fd).
appendMode : True if the file is in append mode, i.e., if the
flag O.append is set in #1(getfl fd).
chunkSize : The recommended size of write operations for
efficient writing.