File system operations
Isis software documentation
File system operations
This document explains the file system manipulation utilities in Isis,
including routines for reading directories and obtaining information
about disk files. For information about how to access the data in
disk files, see the input and
output ports documentation.
Basic file system utilities
(remove-file filename) # permanently remove a disk file
(rename-file fromfilename tofilename) # rename a disk file
(copy-file fromfilename tofilename) # copy a disk file
(create-directory dirname) # create a new directory
(read-directory) # read current directory, return list of filenames
(read-directory dirname) # read the named directory
You can remove, rename, and copy disk files using the first three
functions listed above. create-directory creates a new
directory in the file system at the given location. These four
routines return True if successful or False if not.
read-directory returns a list of string file names in the
directory specified, or the current working directory if no argument
is passed, otherwise it returns Null if there was an error.
This listing will include the current (.) and parent
(..) directories.
-> (read-directory)
[ "." ".." "fontgentest.isis" "fonttest.isis" "makefonts.isis" "viewfonts.isis" ]
File information
(file-accessible? filename) # return True if file exists and is accessible, otherwise False
(file-size filename) # return size of file in bytes, or Null if error
(file-type filename) # return type of file, or Null if error
(file-info filename) # return list of file information (see below)
These routines can be used to get information about files in the file
system. file-type will return a value that matches one of
these pre-defined constants:
file-type-regular
file-type-directory
file-type-block
file-type-character
file-type-fifo
file-info returns a long list of information about a
specified file, or Null if there is an error. You can
extract the information you need by indexing into this list with the
pre-defined constants shown below:
file-info-type # matches one of the file types shown above
file-info-size # size in bytes
file-info-user-read # permissions are either True or False
file-info-user-write
file-info-user-execute
file-info-group-read
file-info-group-write
file-info-group-execute
file-info-other-read
file-info-other-write
file-info-other-execute
file-info-user-id # id of file owner
file-info-set-user-id
file-info-group-id
file-info-set-group-id
file-info-last-access # times are in seconds since jan 1 1970
file-info-last-modification
file-info-last-status-change
The following example shows how to find the size and write permission
status of a file garb.c:
(set garbinfo (file-info "garb.c"))
(set garbsize (garbinfo file-info-size))
(set garbwriteperm (garbinfo file-info-user-write))