This unit contains some utility procedures for Shell scripting and for
some file operations.
This unit uses the extras and regex units.
-
- [procedure] (absolute-pathname? PATHNAME)
-
Returns #t if the string PATHNAME names an absolute
pathname, and returns #f otherwise.
- [procedure] (decompose-pathname PATHNAME)
-
Returns three values: the directory-, filename- and extension-components
of the file named by the string PATHNAME. For any component
that is not contained in PATHNAME, #f is returned.
- [procedure] (make-pathname DIRECTORY FILENAME [EXTENSION
- )]
- [procedure] (make-absolute-pathname DIRECTORY FILENAME [EXTENSION
- ]
Returns a string that names the file with the
components DIRECTORY, FILENAME and (optionally)
EXTENSION. DIRECTORY can be #f (meaning no
directory component), a string or a list of strings. FILENAME
and EXTENSION should be strings or #f.
make-absolute-pathname returns always an absolute pathname.
- [procedure] (pathname-directory PATHNAME)
-
- [procedure] (pathname-file PATHNAME)
-
- [procedure] (pathname-extension PATHNAME)
-
Accessors for the components of PATHNAME. If the pathname does
not contain the accessed component, then #f is returned.
- [procedure] (pathname-replace-directory PATHNAME DIRECTORY)
-
- [procedure] (pathname-replace-file PATHNAME FILENAME)
-
- [procedure] (pathname-replace-extension PATHNAME EXTENSION)
-
Return a new pathname with the specified component of PATHNAME
replaced by a new value.
- [procedure] (pathname-strip-directory PATHNAME)
-
- [procedure] (pathname-strip-extension PATHNAME)
-
Return a new pathname with the specified component of PATHNAME
stripped.
-
- [procedure] (create-temporary-file [EXTENSION])
-
Creates an empty temporary file and returns its pathname. If
EXTENSION is not given, then .tmp is used. If the
environment variable TMPDIR, TEMP or TMP is set,
then the pathname names a file in that directory.
-
- [procedure] (delete-file* FILENAME)
-
If the file FILENAME exists, it is deleted and #t
is returned. If the file does not exist, nothing happens and #f
is returned.
-
- [procedure] (for-each-line PROCEDURE [PORT])
-
Calls PROCEDURE for each line read from PORT (which defaults to the
value of (current-input-port). The argument passed to PORCEDURE
is a string with the contents of the line, excluding any line-terminators.
When all input has been read from the port, for-each-line returns some unspecified value.
- [procedure] (for-each-argv-line PROCEDURE)
-
Opens each file listed on the command line in order, passing one line
at a time into PROCEDURE. The filename - is interpreted as
(current-input-port). If no arguments are given on the command line
it again uses the value of (current-input-port).
This code will act as a simple Unix cat(1) command:
(for-each-argv-line print)
- [procedure] (system* FORMATSTRING ARGUMENT1 ...)
-
Similar to (system (sprintf FORMATSTRING ARGUMENT1 ...)),
but signals an error if the invoked program should return a nonzero
exit status.