CL-FAD - A portable pathname library for Common Lisp


 

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.

Download shortcut: http://weitz.de/files/cl-fad.tar.gz.


 

Contents

  1. Download and installation
  2. Supported Lisp implementations
  3. The CL-FAD dictionary
    1. directory-pathname-p
    2. pathname-as-directory
    3. pathname-as-file
    4. file-exists-p
    5. directory-exists-p
    6. list-directory
    7. walk-directory
    8. delete-directory-and-files
    9. copy-file
    10. copy-stream
  4. Acknowledgements

 

Download and installation

CL-FAD together with this documentation can be downloaded from http://weitz.de/files/cl-fad.tar.gz. The current version is 0.6.3.

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.

Luís Oliveira maintains a darcs repository of CL-FAD at http://common-lisp.net/~loliveira/ediware/.

If you want to send patches, please read this first.
 

Supported Lisp implementations

The following Common Lisp implementations are currently supported:

I'll gladly accepts patches to make CL-FAD work on other platforms.
 

The CL-FAD dictionary


[Function]
directory-pathname-p pathspec => generalized-boolean


Returns NIL if pathspec (a pathname designator) does not designate a directory, pathspec otherwise. It is irrelevant whether the file or directory designated by pathspec does actually exist.


[Function]
pathname-as-directory pathspec => pathname


Converts the non-wild pathname designator pathspec to directory form, i.e. it returns a pathname which would return a true value if fed to DIRECTORY-PATHNAME-P.


[Function]
pathname-as-file pathspec => pathname


Converts the non-wild pathname designator pathspec to file form, i.e. it returns a pathname which would return a NIL value if fed to DIRECTORY-PATHNAME-P.


[Function]
file-exists-p pathspec => generalized-boolean


Checks whether the file named by the pathname designator pathspec 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 by PATHNAME-AS-DIRECTORY.


[Function]
directory-exists-p pathspec => generalized-boolean


Checks whether the file named by the pathname designator pathspec 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 by PATHNAME-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 designator dirname. The pathnames of sub-directories are returned in directory form - see PATHNAME-AS-DIRECTORY.


[Function]
walk-directory dirname fn &key directories if-does-not-exist test => |


Recursively applies the function designated by the function designator fn to all files within the directory named by the non-wild pathname designator dirname and all of its sub-directories. fn will only be applied to files for which the function test returns a true value. (The default value for test always returns true.) If directories is not NIL, fn and test are applied to directories as well. If directories is :DEPTH-FIRST, fn will be applied to the directory's contents first. If directories is :BREADTH-FIRST and test returns NIL, the directory's content will be skipped. if-does-not-exist must be one of :ERROR or :IGNORE where :ERROR (the default) means that an error will be signaled if the directory dirname 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 designator dirname including dirname 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 directory dirname does not exist.


[Function]
copy-file from to &key overwrite => |


Copies the file designated by the non-wild pathname designator from to the file designated by the non-wild pathname designator to. If overwrite is true (the default is NIL) overwrites the file designtated by to if it exists.


[Function]
copy-stream from to &optional checkp => |


Copies into to (a stream) from from (also a stream) until the end of from is reached. The streams should have the same element type unless they are bivalent. If checkp is true (which is the default), the function will signal an error if the element types aren't the same.

 

Acknowledgements

The original code for this library was written by Peter Seibel for his book Practical Common Lisp. I added some stuff and made sure it worked properly on Windows, specifically with CCL. Thanks to James Bielman, Maciek Pasternacki, Jack D. Unrue, Gary King, and Douglas Crosher who sent patches for OpenMCL, ECL, ABCL, MCL, and Scieneer CL.

$Header: /usr/local/cvsrep/cl-fad/doc/index.html,v 1.33 2009/09/30 14:23:12 edi Exp $

BACK TO MY HOMEPAGE