Next Prev Up Top Contents Index

directory

Function
Summary

Determines which files on the system have named matching a given pathname.

Package

common-lisp

Signature

directory pathname &key test directories check-for-subs link-transparency non-existent-link-destinations => pathnames

Arguments

pathname

A pathname, string, or file-stream.

test

Filtering test (only pathnames matching the test are collected).

directories

If non- nil then directories are included in the collection.

check-for-subs

If non- nil (the default), then pathnames representing directories have null name components.

link-transparency

If nil , then symbolic links are not followed. This means that returned names are not necessarily truenames, but has the useful feature that the pathname-directory of each pathname returned is the directory supplied as argument.

Default value is given by the special variable, system::*directory-link-transparency* , which defaults to non- nil . By setting this variable to nil , you can get the old behavior of directory .

non-existent-link-destinations

If this is non- nil , then the pathname pointed to by a symbolic link appears in the output whether or not this file actually exists. If :link-transparency is non- nil and :non-existent-link-destinations is nil (i.e. the default case), then symbolic links to nonexistent files do not appear.

The default value is nil .

Values

pathnames

A list of physical pathnames.

Description

directory collects all the pathnames matching the given pathname.

directory returns truenames, conforming to the ANSI specification for Common Lisp. Some programs may depend on the old behavior, however (and directory is slower if it has to find the truename for every file in the directory), and so two keyword arguments are available so that the old behavior can be still be used: link-transparency and non-existent-link-destinations .

Because truenames are now returned, the entries . and .. no longer show up in the output of directory . This means, for instance, that

(directory #P"/usr/users/")

does not include #P"/usr" , which is the truename of #P"/usr/users/.."

The specification is unclear as to the appropriate behavior of directory in the presence of links to non-existent files or directories. For example, if the directory contains foo , which is a symbolic link to bar , and there is no file named bar , should bar show up in the directory listing? A keyword argument has been added which lets you control this behavior.

Example
CL-USER 15 > (pprint (directory "."))
 (#P"C:/Program Files/Xanalys/LispWorks/lib/"
 #P"C:/Program Files/Xanalys/LispWorks/lispworks-  4200.exe"
 #P"C:/Program Files/Xanalys/LispWorks/readme.txt"
 #P"C:/Program Files/Xanalys/LispWorks/DeIsL1.isu"
 #P"C:/Program Files/Xanalys/LispWorks/MSVCRT.DLL")

LispWorks Reference Manual - 14 Dec 2001

Next Prev Up Top Contents Index