Posix.IO structure
signature POSIX_IO
structure IO : POSIX_IO
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[CITE].
eqtype file_desc
eqtype pid
val pipe : unit -> {infd : file_desc, outfd : file_desc}
val dup : file_desc -> file_desc
val dup2 : {old : file_desc, new : file_desc} -> unit
val close : file_desc -> unit
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
datatype whence
= SEEK_SET
| SEEK_CUR
| SEEK_END
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
datatype open_mode
= O_RDONLY
| O_WRONLY
| O_RDWR
val dupfd : {old : file_desc, base : file_desc}
-> file_desc
val getfd : file_desc -> FD.flags
val setfd : file_desc * FD.flags -> unit
val getfl : file_desc -> O.flags * open_mode
val setfl : file_desc * O.flags -> unit
val lseek : file_desc * Position.int * whence
-> Position.int
val fsync : file_desc -> unit
datatype lock_type
= F_RDLCK
| F_WRLCK
| F_UNLCK
structure FLock : sig
type flock
val flock : {
ltype : lock_type,
whence : whence,
start : Position.int,
len : Position.int,
pid : pid option
} -> flock
val ltype : flock -> lock_type
val whence : flock -> whence
val start : flock -> Position.int
val len : flock -> Position.int
val pid : flock -> pid option
end
val getlk : file_desc * FLock.flock -> FLock.flock
val setlk : file_desc * FLock.flock -> FLock.flock
val setlkw : file_desc * FLock.flock -> FLock.flock
val mkBinReader : {
fd : file_desc,
name : string,
initBlkMode : bool
} -> BinPrimIO.reader
val mkTextReader : {
fd : file_desc,
name : string,
initBlkMode : bool
} -> TextPrimIO.reader
val mkBinWriter : {
fd : file_desc,
name : string,
appendMode : bool,
initBlkMode : bool,
chunkSize : int
} -> BinPrimIO.writer
val mkTextWriter : {
fd : file_desc,
name : string,
appendMode : bool,
initBlkMode : bool,
chunkSize : int
} -> TextPrimIO.writer
eqtype file_desc
eqtype pid
val pipe : unit -> {infd : file_desc, outfd : file_desc}
dup fd
Posix.FileSys.fdToWord) of the returned file descriptor is the lowest one available. It is equivalent to dupfd {old=fd, base=Posix.FileSys.wordToFD 0w0}.
dup2 {old, new}
close fd
readVec (fd, n)
0). It raises the Size exception if n < 0.
readArr (fd, slice)
0, although 0 is also returned if the slice is empty. This function will raise OS.SysErr if there is some problem with the underlying system call (e.g., the file is closed).
writeVec (fd, slice)
writeArr (fd, slice)
OS.SysErr if there is some problem with the underlying system call (e.g., the file is closed or there is insufficient disk space).
structure FD
val cloexec : flags
exec, etc.). If cloexec is not set, the open file descriptor will be inherited by the new process.
structure O
val append : flags
val nonblock : flags
val sync : flags
datatype open_mode
= O_RDONLY
| O_WRONLY
| O_RDWR
dupfd {old, base}
Posix.FileSys.fdToWord and Posix.FileSys.wordToFD. It corresponds to the POSIX fcntl function with the F_DUPFD command.
getfd fd
fcntl function with the F_GETFD command.
setfd (fd, fl)
fcntl function with the F_SETFD command.
getfl fd
fcntl function with the F_GETFL command.
setfl (fd, fl)
fcntl function with the F_SETFL command.
lseek (fd, off, wh)
SEEK_SET; to its current value plus off bytes if wh is SEEK_CUR; or, to the size of the file plus off bytes if wh is SEEK_END. Note that off may be negative.
fsync fd
datatype lock_type
= F_RDLCK
| F_WRLCK
| F_UNLCK
F_RDLCK indicates a shared or read lock. F_WRLCK indicates an exclusive or write lock. F_WRLCK indicates a lock is unlocked or inactive.
structure FLock
type flock
flock function below.
flock {ltype, whence, start, len, pid}
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.
val ltype : flock -> lock_type
val whence : flock -> whence
val start : flock -> Position.int
val len : flock -> Position.int
val pid : flock -> pid option
flock value.
getlk (fd, fl)
fcntl function with the F_GETLK command.
setlk (fd, fl)
fcntl function with the F_SETLK command.
val setlkw : file_desc * FLock.flock -> FLock.flock
setlk function above except that setlkw waits on blocked locks until they are released. It corresponds to the POSIX fcntl function with the F_SETLKW command.
val mkBinReader : {
fd : file_desc,
name : string,
initBlkMode : bool
} -> BinPrimIO.reader
val mkTextReader : {
fd : file_desc,
name : string,
initBlkMode : bool
} -> TextPrimIO.reader
fdopen.
The argument fields have the following meanings:
fd
name
initBlkMode
O.nonblock is set in #1(getfl fd).
val mkBinWriter : {
fd : file_desc,
name : string,
appendMode : bool,
initBlkMode : bool,
chunkSize : int
} -> BinPrimIO.writer
val mkTextWriter : {
fd : file_desc,
name : string,
appendMode : bool,
initBlkMode : bool,
chunkSize : int
} -> TextPrimIO.writer
fdopen.
The argument fields have the following meanings:
fd
name
initBlkMode
O.nonblock is set in #1(getfl fd).
appendMode
O.append is set in #1(getfl fd).
chunkSize
BIT_FLAGS,OS.IO,Posix,Posix.Error,Posix.FileSys,Posix.IO
Question:
Why don't mk*Reader allow a chunkSize parameter? Or why do mk*Writer allow this?
Generated April 12, 2004
Last Modified July 1, 2002
Comments to John Reppy.
This document may be distributed freely over the internet as long as the copyright notice and license terms below are prominently displayed within every machine-readable copy.
|
Copyright © 2004 AT&T and Lucent Technologies. All rights reserved.
Permission is granted for internet users to make one paper copy for their
own personal use. Further hardcopy reproduction is strictly prohibited.
Permission to distribute the HTML document electronically on any medium
other than the internet must be requested from the copyright holders by
contacting the editors.
Printed versions of the SML Basis Manual are available from Cambridge
University Press.
To order, please visit
www.cup.org (North America) or
www.cup.cam.ac.uk (outside North America). |