Next: Directories
Up: Filesystem Utilities
Previous: Pathnames
The file management utilities are:
-
(file-exists? path)
returns #t if a file (not a directory)
path exists, #f otherwise. Unlike some other
procedures that take a path argument, this procedure never raises
the exn:i/o:filesystem:username exception.
-
(link-exists? path)
returns #t if a link path exists (Unix and
MacOS), #f otherwise. Note that the predicates
file-exists? or directory-exists? work on the final
destination of a link or series of links, while link-exists?
only follows links to resolve the base part of path (i.e.,
everything except the last name in the path). This procedure never
raises the exn:i/o:filesystem:username exception.
-
(delete-file path)
deletes the file with pathname path if it exists, returning
void if a file was deleted successfully, otherwise the
exn:i/o:filesystem:file exception is raised. If path is a link, the link
is deleted rather than the destination of the link.
-
(rename-file-or-directory old new)
renames the file or directory with pathname old -- if it exists
-- to the pathname new. If the file or directory is
renamed successfully, void is returned, otherwise the
exn:i/o:filesystem:rename exception is raised. This procedure can be used
to move a file/directory to a different directory (on the same disk)
as well as rename a file/directory within a directory. The pathname
new cannot refer to an existing file or directory. If old
is a link, the link is renamed rather than the destination of the
link.
-
(file-or-directory-modify-seconds path)
returns the file or directory's last modification date as
platform-specific seconds (see also section 11.4). If no file or
directory path exists, the exn:i/o:filesystem:file exception is raised.
-
(file-or-directory-permissions path) returns a list containing
'read, 'write, and/or 'execute
for the given file or directory path. If no such file or directory
exists, the exn:i/o:filesystem:file exception is raised.
-
(file-size path) returns the (logical) size of
the specified file. (Under MacOS, this is the sum of the data fork and
resource fork sizes.) If no such file exists, , the
exn:i/o:filesystem:file exception is raised.
-
(copy-file src dest)
creates the file dest as a copy of src. If the file is
successfully copied, void is returned, otherwise the
exn:i/o:filesystem:rename exception is raised. If dest already exists,
the copy will fail. File permissions are preserved in the copy. Under
MacOS, the resource fork is also preserved in the copy.
Next: Directories
Up: Filesystem Utilities
Previous: Pathnames
PLT