20.3. Directory functions

20.3.1. Function EXT:PROBE-DIRECTORY
20.3.2. Function DIRECTORY
20.3.3. Function EXT:DIR
20.3.4. Function EXT:CD
20.3.5. Function EXT:DEFAULT-DIRECTORY
20.3.6. Function EXT:MAKE-DIRECTORY
20.3.7. Function EXT:DELETE-DIRECTORY
20.3.8. Function EXT:RENAME-DIRECTORY

20.3.1. Function EXT:PROBE-DIRECTORY

(EXT:PROBE-DIRECTORY pathname) tests whether pathname exists and is a directory. It will, unlike PROBE-FILE or TRUENAME, not SIGNAL an ERROR if the parent directory of pathname does not exist.

20.3.2. Function DIRECTORY

(DIRECTORY &OPTIONAL pathname &KEY :FULL :CIRCLE :IF-DOES-NOT-EXIST) can run in two modes:

  • If pathname contains no name or type component, a list of all matching directories is produced. E.g., (DIRECTORY "/etc/*/") lists all subdirectories in the directory #P"/etc/".
  • Otherwise a list of all matching files is returned. E.g., (DIRECTORY "/etc/*") lists all regular files in the directory #P"/etc/".

If you want all the files and subdirectories in the current directory, you should use (NCONC (DIRECTORY "*/") (DIRECTORY "*")). If you want all the files and subdirectories in all the subdirectories under the current directory (similar to the ls -R UNIX command), use (NCONC (DIRECTORY "**/") (DIRECTORY "**/*")).

Keyword arguments accepted by DIRECTORY

:FULL
If this argument is non-NIL, additional information is returned: for each matching file you get a LIST of at least four elements (file-pathname file-truename file-write-date-as-decoded-time file-length).
:CIRCLE
If this argument is non-NIL, DIRECTORY avoids endless loops that may result from symbolic links.
:IF-DOES-NOT-EXIST

This argument controls the treatment of links pointing to non-existent files and can take the following values:

:DISCARD (default)
discard the bad directory entries
:ERROR
an ERROR is SIGNALed on bad directory entries (this corresponds to the default behavior of DIRECTORY in CMU CL)
:KEEP
keep bad directory entries in the returned list (this roughly corresponds to the (DIRECTORY ... :TRUNAMEP NIL) call in CMU CL)
:IGNORE
Similar to :DISCARD, but also do not signal an error when a directory is unaccessible (contrary to the [ANSI CL standard] specification).

20.3.3. Function EXT:DIR

(EXT:DIR &OPTIONAL pathname) is like DIRECTORY, but displays the pathnames instead of returning them. (EXT:DIR) shows the contents of the current directory.

20.3.4. Function EXT:CD

(EXT:CD pathname) sets the current working directory, (EXT:CD) returns it.

Platform Dependent: UNIX platform only.
(EXT:CD [pathname]) manages the current directory.
Platform Dependent: Win32 platform only.
(EXT:CD [pathname]) manages the current device and the current directory.

20.3.5. Function EXT:DEFAULT-DIRECTORY

(EXT:DEFAULT-DIRECTORY) is equivalent to (EXT:CD). (SETF (EXT:DEFAULT-DIRECTORY) pathname) is equivalent to (EXT:CD pathname), except for the return value.

20.3.6. Function EXT:MAKE-DIRECTORY

(EXT:MAKE-DIRECTORY directory) creates a new subdirectory.

20.3.7. Function EXT:DELETE-DIRECTORY

(EXT:DELETE-DIRECTORY directory) removes an (empty) subdirectory.

20.3.8. Function EXT:RENAME-DIRECTORY

(EXT:RENAME-DIRECTORY old-directory new-directory) renames a subdirectory to a new name.


These notes document CLISP version 2.49Last modified: 2010-07-07