These procedures are in structures
Directory streams are like input ports, with each read operation returning the next name in the directory.
(open-directory-stream name) -> directory
(directory-stream? x) -> boolean
(read-directory-stream directory) -> name or #f
Open-directory-streamopens a new directory stream.
Directory-stream?is a predicate that recognizes directory streams.
Read-directory-streamreturns the next name in the directory or
#fif all names have been read.
Close-directory-streamcloses a directory stream.
Open-fileopens a port to the file named by string
file-optionsargument determines various aspects of the returned port. The optional
file-modeargument is used only if the file to be opened does not already exist. The returned port is an input port if
read-only; otherwise it returns an output port.
Dup-switching-modecan be used to open an input port for output ports opened with the
(file-options-on? file-options file-options) -> boolean
file-optionsreturns a file-option with the indicated options set.
File-options-on?returns true if its first argument includes all of the options listed in the second argument. The following file options may be used with
Only one of the last three options may be used.
create file if it does not already exist; a file-mode argument is required with this option
an error will be raised if this option and
createare both set and the file already exists
pathis a terminal device this option causes the terminal to not become the controlling terminal of the process
file is truncated
writes are appended to existing contents
read and write operations do not block
port may not be written
file descriptor may be read or written
port may not be read
returns an output port that writes to a newly-created file that can be read by anyone and written only by the owner. Once the file exists,(open-file "some-file.txt" (file-options create write-only) (file-mode read owner-write))
will open an output port that appends to the file.(open-file "some-file.txt" (file-options append write-only))
nonblocking options and the read/write nature of
the port can be read using
nonblocking options can be set
To keep port operations from blocking the Scheme 48 process, output
ports are set to be nonblocking at the time of creation (input ports
are managed using
You can use
set-i/o-flags! to make an output port blocking, for
example just before a fork, but care should be exercised.
The Scheme 48 runtime code may get confused if an I/O operation blocks.
file-mode. Bits set in
file-modeare cleared in the modes of any files or directories created by the current process.
newbe a new link to the file pointed to by path
existing. The two paths must be in the same file system.
Unlinkremoves the link indicated by
Remove-directoryremoves the indicated (empty) directory.
Renamemoves the file pointed to by
old-pathto the location pointed to by
new-path(the two paths must be in the same file system). Any other links to the file remain unchanged.
(accessible? path access-mode . more-modes) -> boolean
Accessible?returns true if
pathis a file that can be accessed in the listed mode. If more than one mode is specified
accessible?returns true if all of the specified modes are permitted. The
(get-file-info name) -> file-info
(get-file/link-info name) -> file-info
(get-port-info fd-port) -> file-info
get-file/link-infoboth return a file info record for the named file.
Get-file-infofollows symbolic links while
Get-port-inforeturns a file info record for the file which
portreads from or writes to. An error is raised if
fd-portdoes not read from or write to a file descriptor.
File-info?is a predicate for file-info records.
File-info-nameis the name which was used to get
file-info, either as passed to
get-file/link-info, or used to open the port passed to
(file-info-type file-info) -> file-type
(file-type? x) -> boolean
(file-type-name file-type) -> symbol
File-info-typereturns the type of the file, as a file-type object File types may be compared using
eq?. The valid file types are:
socket are not required by POSIX.
(file-info-owner file-info) -> user-id
(file-info-group file-info) -> group-id
(file-info-mode file-info) -> file-mode
(file-info-last-access file-info) -> time
(file-info-last-modification file-info) -> time
(file-info-last-info-change file-info) -> time
A file mode is a boxed integer representing a file protection mask.
(file-mode? x) -> boolean
(file-mode+ file-mode ...) -> file-mode
(file-mode- file-mode0 file-mode1) -> file-mode
File-modeis syntax for creating file modes. The mode-names are listed below.
File-mode?is a predicate for file modes.
File-mode+returns a mode that contains all of permissions of its arguments.
File-mode-returns a mode that has all of the permissions of
file-mode0that are not in
(file-mode=? file-mode0 file-mode1) -> boolean
(file-mode<=? file-mode0 file-mode1) -> boolean
(file-mode>=? file-mode0 file-mode1) -> boolean
File-mode=?returns true if the two modes are exactly the same.
File-mode<=?returns true if
file-mode0has a subset of the permissions of
file-mode<=?with the arguments reversed.
file-mode->integertranslate file modes to and from the classic Unix file mode masks. These may not be the masks used by the underlying OS.
Permission name Bit mask
set user id when executing
set group id when executing
read by owner
write by owner
execute (or search) by owner
read by group
write by group
execute (or search) by group
read by others
write by others
execute (or search) by others
Names for sets of permissions
read, write, and execute by owner
read, write, and execute by group
read, write, and execute by others
read by anyone
write by anyone
execute by anyone
anything by anyone
Previous: Files and directories | Next: Files and directories