All Manuals > LispWorks® User Guide and Reference Manual > 37 The HCL Package

fast-directory-files

fdf-handle-directory-p

fdf-handle-directory-string

fdf-handle-last-access

fdf-handle-last-modify

fdf-handle-link-p

fdf-handle-size

fdf-handle-writable-p Functions

Summary

Maps a callback on the names of files in a specified directory and returns a list of those for which the callback returned true. The callback can retrieve information about the files.

Package

hcl

Signatures

fast-directory-files dir-pathname callback => result

fdf-handle-directory-p fdf-handle => directory-p

fdf-handle-directory-string fdf-handle => directory-string

fdf-handle-last-access fdf-handle => last-access

fdf-handle-last-modify fdf-handle => last-modify

fdf-handle-link-p fdf-handle => link-p

fdf-handle-size fdf-handle => size

fdf-handle-writable-p fdf-handle => writable-p

Arguments
dir-pathname
A pathname designator without wild characters in its directory path.
callback
A function designator.
fdf-handle
An opaque object used to retrieve information about a file in dir-pathname.
Values
result
A list of strings.
directory-p
A boolean.
directory-string
A string.
last-access, last-modify
Integers.
link-p
A boolean.
size
An integer.
writable-p
A boolean.
Description

The function fast-directory-files maps the function callback on the names of the files in directory specified by dir-pathname, and returns a list of the names for which callback returned non-nil.

dir-pathname must be a pathname designator, which does not contain wild characters in its directory path. To be useful, it should either be a directory (with no name and type), or with wild name and/or type.

callback must be a function of two arguments, the name of the file and an opaque object (referred to as fdf-handle) which can be used to retrieve information about the file, by calling any of the fdf-handle-… functions documented on this page.

fast-directory-files traverses the files that match dir-pathname in an undefined way, and for each file calls callback with the file's name (not including the directory) and a fdf-handle. If callback returns non-nil it adds the name to a list. It returns the list of names for which callback returned non-nil. Note that the names do not contain the directory name.

fdf-handle can be accessed by the following readers. Functions named in parentheses would return the same value when called on the full path of the file:

fdf-handle-size returns the size of the file in bytes.

fdf-handle-last-modify returns the universal time of the last modification of the file (cl:file-write-date).

fdf-handle-last-access returns the universal time of the last access of the file.

fdf-handle-directory-p is a predicate for whether the file is a directory (file-directory-p).

fdf-handle-link-p is a predicate for whether the file is a soft link (always returns nil on Windows).

fdf-handle-writable-p is a predicate for whether the file is writable (file-writable-p).

fdf-handle-directory-string returns a string with the directory path followed by a separator. Therefore the full path of the file can be constructed by:

(string-append (fdf-handle-directory-string fdf-handle)
               name)
Notes

fdf-handle can be used only within the dynamic scope of the callback to which it was passed.

See also

directory
27.14.2 Fast access to files in a directory


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:35