include "sys.m"; sys:= load Sys Sys->PATH; open: fn(file: string, omode: int) : ref FD; create:fn(file: string, omode, perm: int): ref FD;
OREAD
|
open for reading
|
OWRITE
|
open for writing
|
ORDWR
|
open for reading and writing
|
The following values may be OR'ed with the above values for additional actions:
OTRUNC
|
Truncate the file before opening it; this requires write permission even if omode is OREAD.
|
ORCLOSE
|
Remove the file on closure.
|
The open function returns nil if the file does not exist or the user does not have permission to open it as requested (see stat, fstat, fwstat, wstat - get and put file status for a description of permissions).
create (file, omode, perm)
The create function creates a new file or prepares to rewrite an existing file. The function opens it according to omode as described for open, and returns an associated file descriptor.
If the file already exists, it is truncated to 0 length, and the permissions, owner, and group remain unchanged.
file mode bits in perm
The create function returns nil if the path up to the last element of file cannot be evaluated, if the user does not have write permission in the final directory, or if the file already exists and does not permit the access defined by omode.
If the file is new and the directory in which it is created is a union directory (see Limbo System Module), then the directory where the file is created depends on the structure of the union: see bind, mount, unmount - change file name space.
Caveat
There is no explicit close routine; when the last reference to the file descriptor is released, the system closes the associated file.
Limbo System Module
|
bind, mount, unmount - change file name space
|
stat, fstat, fwstat, wstat - get and put file status
|
open, create - prepare a fid for I/O on a file in Chapter 3
|