Abstract
CL-FAD (for "Files and Directories") is a thin layer atop Common Lisp's standard pathname functions. It is intended to provide some unification between current CL implementations on Windows, OS X, Linux, and Unix. Most of the code was written by Peter Seibel for his book Practical Common Lisp.CL-FAD comes with a BSD-style license so you can basically do with it whatever you want.
CL-FAD comes with simple system definitions for MK:DEFSYSTEM and asdf so you can either adapt it
to your needs or just unpack the archive and from within the CL-FAD
directory start your Lisp image and evaluate the form
(mk:compile-system "cl-fad")
- or (asdf:oos 'asdf:load-op :cl-fad)
for asdf - which should compile and load the whole
system.
Installation via asdf-install should as well
be possible. Plus, there are ports
for Gentoo Linux thanks to Matthew Kennedy
and for Debian Linux thanks to René van Bevern.
If for some reason you can't or don't want to use MK:DEFSYSTEM or asdf you
can just LOAD
the file load.lisp
.
The following Common Lisp implementations are currently supported:
[Function]
directory-pathname-p pathspec => generalized-boolean
ReturnsNIL
ifpathspec
(a pathname designator) does not designate a directory,pathspec
otherwise. It is irrelevant whether the file or directory designated bypathspec
does actually exist.
[Function]
pathname-as-directory pathspec => pathname
Converts the non-wild pathname designatorpathspec
to directory form, i.e. it returns a pathname which would return a true value if fed toDIRECTORY-PATHNAME-P
.
[Function]
pathname-as-file pathspec => pathname
Converts the non-wild pathname designatorpathspec
to file form, i.e. it returns a pathname which would return aNIL
value if fed toDIRECTORY-PATHNAME-P
.
[Function]
file-exists-p pathspec => generalized-boolean
Checks whether the file named by the pathname designatorpathspec
exists and returns its truename if this is the case,NIL
otherwise. The truename is returned in "canonical" form, i.e. the truename of a directory is returned in directory form as if byPATHNAME-AS-DIRECTORY
.
[Function]
directory-exists-p pathspec => generalized-boolean
Checks whether the file named by the pathname designatorpathspec
exists and if it is a directory. Returns its truename if this is the case,NIL
otherwise. The truename is returned in directory form as if byPATHNAME-AS-DIRECTORY
.
[Function]
list-directory dirname => list
Returns a fresh list of pathnames corresponding to the truenames of all files within the directory named by the non-wild pathname designatordirname
. The pathnames of sub-directories are returned in directory form - seePATHNAME-AS-DIRECTORY
.
[Function]
walk-directory dirname fn &key directories if-does-not-exist test => |
Recursively applies the function designated by the function designatorfn
to all files within the directory named by the non-wild pathname designatordirname
and all of its sub-directories.fn
will only be applied to files for which the functiontest
returns a true value. (The default value fortest
always returns true.) Ifdirectories
is true (the default isNIL
),fn
andtest
are applied to directories as well, andfn
is guaranteed to be applied to the directory's contents first.if-does-not-exist
must be one of:ERROR
or:IGNORE
where:ERROR
(the default) means that an error will be signaled if the directorydirname
does not exist.
[Function]
delete-directory-and-files dirname&key if-does-not-exist => |
Recursively deletes all files and directories within the directory designated by the non-wild pathname designatordirname
includingdirname
itself.if-does-not-exist
must be one of:ERROR
or:IGNORE
where:ERROR
(the default) means that an error will be signaled if the directorydirname
does not exist.
[Function]
copy-file from to &key overwrite => |
Copies the file designated by the non-wild pathname designatorfrom
to the file designated by the non-wild pathname designatorto
. Ifoverwrite
is true (the default isNIL
) overwrites the file designtated byto
if it exists.
$Header$