Go to the first, previous, next, last section, table of contents.
These procedures allow querying and setting file system attributes
(such as owner,
permissions, sizes and types of files); deleting, copying, renaming and
linking files; creating and removing directories and querying their
contents; syncing the file system and creating special files.
- primitive: access? path how
-
Returns
#t
if path corresponds to an existing
file and the current process
has the type of access specified by how, otherwise
#f
.
how should be specified
using the values of the variables listed below. Multiple values can
be combined using a bitwise or, in which case #t
will only
be returned if all accesses are granted.
Permissions are checked using the real id of the current process,
not the effective id, although it's the effective id which determines
whether the access would actually be granted.
- Variable: R_OK
-
test for read permission.
- Variable: W_OK
-
test for write permission.
- Variable: X_OK
-
test for execute permission.
- Variable: F_OK
-
test for existence of the file.
- primitive: stat obj
-
Returns an object containing various information
about the file determined by obj.
obj can be a string containing a file name or a port or integer file
descriptor which is open on a file (in which case
fstat
is used
as the underlying system call).
The object returned by stat
can be passed as a single parameter
to the following procedures, all of which return integers:
stat:dev
-
The device containing the file.
stat:ino
-
The file serial number, which distinguishes this file from all other
files on the same device.
stat:mode
-
The mode of the file. This includes file type information
and the file permission bits. See
stat:type
and stat:perms
below.
stat:nlink
-
The number of hard links to the file.
stat:uid
-
The user ID of the file's owner.
stat:gid
-
The group ID of the file.
stat:rdev
-
Device ID; this entry is defined only for character or block
special files.
stat:size
-
The size of a regular file in bytes.
stat:atime
-
The last access time for the file.
stat:mtime
-
The last modification time for the file.
stat:ctime
-
The last modification time for the attributes of the file.
stat:blksize
-
The optimal block size for reading or writing the file, in bytes.
stat:blocks
-
The amount of disk space that the file occupies measured in units of
512 byte blocks.
In addition, the following procedures return the information
from stat:mode in a more convenient form:
stat:type
-
A symbol representing the type of file. Possible values are
regular, directory, symlink, block-special, char-special,
fifo, socket and unknown
stat:perms
-
An integer representing the access permission bits.
- primitive: lstat path
-
Similar to
stat
, but does not follow symbolic links, i.e.,
it will return information about a symbolic link itself, not the
file it points to. path must be a string.
- primitive: readlink path
-
Returns the value of the symbolic link named by
path (a string), i.e., the
file that the link points to.
- primitive: chown obj owner group
-
Change the ownership and group of the file referred to by obj to
the integer userid values owner and group. obj can be
a string containing a file name or a port or integer file descriptor
which is open on the file (in which case fchown is used as the underlying
system call). The return value
is unspecified.
If obj is a symbolic link, either the
ownership of the link or the ownership of the referenced file will be
changed depending on the operating system (lchown is
unsupported at present). If owner or group is specified
as -1
, then that ID is not changed.
- primitive: chmod obj mode
-
Changes the permissions of the file referred to by obj.
obj can be a string containing a file name or a port or integer file
descriptor which is open on a file (in which case
fchmod
is used
as the underlying system call).
mode specifies
the new permissions as a decimal number, e.g., (chmod "foo" #o755)
.
The return value is unspecified.
- primitive: utime path [actime] [modtime]
-
utime
sets the access and modification times for
the file named by path. If actime or modtime
is not supplied, then the current time is used.
actime and modtime
must be integer time values as returned by the current-time
procedure.
E.g.,
(utime "foo" (- (current-time) 3600))
will set the access time to one hour in the past and the modification
time to the current time.
- primitive: delete-file path
-
Deletes (or "unlinks") the file specified by path.
- primitive: copy-file path-from path-to
-
Copy the file specified by path-from to path-to.
The return value is unspecified.
- primitive: rename-file path-from path-to
-
Renames the file specified by path-from to path-to.
The return value is unspecified.
- primitive: truncate-file obj size
-
Truncates the file referred to by obj to at most size bytes.
obj can be a string containing a file name or an integer file
descriptor or port open for output on the file. The underlying system
calls are
truncate
and ftruncate
.
The return value is unspecified.
- primitive: link path-from path-to
-
Creates a new name path-to in the file system for the file
named by path-from. If path-from is a symbolic link, the
link may or may not be followed depending on the system.
- primitive: symlink path-from path-to
-
Create a symbolic link named path-to with the value (i.e., pointing to)
path-from. The return value is unspecified.
- primitive: mkdir path [mode]
-
Create a new directory named by path. If mode is omitted
then the permissions of the directory file are set using the current
umask. Otherwise they are set to the decimal value specified with
mode. The return value is unspecified.
- primitive: rmdir path
-
Remove the existing directory named by path. The directory must
be empty for this to succeed. The return value is unspecified.
- primitive: opendir path
-
Open the directory specified by path and return a directory
port.
- primitive: readdir port
-
Return (as a string) the next directory entry from the directory port
port. If there is no remaining entry to be read then the
end of file object is returned.
- primitive: rewinddir port
-
Reset the directory port port so that the next call to
readdir
will return the first directory entry.
- primitive: closedir port
-
Close the directory port port.
The return value is unspecified.
- primitive: sync
-
Flush the operating system disk buffers.
The return value is unspecified.
- primitive: mknod path type perms dev
-
Creates a new special file, such as a file corresponding to a device.
path specifies the name of the file. type should
be one of the following symbols:
regular, directory, symlink, block-special, char-special,
fifo, or socket. perms (an integer) specifies the file permissions.
dev (an integer) specifies which device the special file refers
to. Its exact interpretation depends on the kind of special file
being created.
E.g.,
(mknod "/dev/fd0" 'block-special #o660 (+ (* 2 256) 2))
The return value is unspecified.
- primitive: tmpnam
-
Create a new file in the file system with a unique name. The return
value is the name of the new file. This function is implemented with
the
tmpnam
function in the system libraries.
Go to the first, previous, next, last section, table of contents.