All Manuals > LispWorks User Guide and Reference Manual > 27 LispWorks' Operating Environment

NextPrevUpTopContentsIndex

27.13 File system interface

27.13.1 Fast access to files in a directory

fast-directory-files gives a faster way to access files than directory, especially in situations when you need to filter based on simple features such as size and access time, or filter based on the name in a more complex way than directory can.

Instead of creating a list of pathnames and returning it, fast-directory-files traverses the files and calls a callback function on each file with its name and an opaque handle, which is referred to as fdf-handle. From this handle, you can retrieve the size, last-access time and last-modify time, and query whether the file is a directory, whether it is a link (for platforms other than Windows), and whether it is writable. The implementation makes the access to the fdf-handle much faster than doing the same by calling directory and then calling cl:file-write-date and similar functions on the result.

When the callback returns non-nil, fast-directory-files collects the filename, otherwise it ignores it. Hence the callback can be used both as a filter and to actually do some work. In many cases, the callback will always return nil, and the call will be used just to map the callback on the file for the "side-effects" of the callback.

fast-directory-files is restricted to one directory level, that is it cannot deal with wild directories.


LispWorks User Guide and Reference Manual - 13 Feb 2015

NextPrevUpTopContentsIndex