WITH-DIRECTORY-ITERATOR
WITH-DIRECTORY-ITERATOR is a proposal of the Common Lisp Utilities family to solve the perpetual portability issues associated with DIRECTORY. A reference implementation can be found in Osicat.

macro

Syntax: WITH-DIRECTORY-ITERATOR (name directory) form* => result*

Arguments and Values:

  • name --- a name suitable for the first argument to a macrolet
  • directory --- a pathname designator with null name, type, and version components
  • forms --- an implicit progn

Description:

Within the lexical scope of the body, name is defined via macrolet such that successive invocations of (name) return the directory entries, one by one.

All entries, including files, directories, symbolic links, etc. are returned, with the exception of "virtual entries" that designate the directory itself or its parent ("." and ".." on POSIX systems).

The order of entries is not guaranteed. The entries are returned as relative pathnames against directory.

Entries that are symbolic links are not resolved, but links that point to directories are interpreted as directories (so that the name, type and version components of the pathname are NIL.)

Once all entries have been returned, further invocations of (name) will all return NIL.

Binds *default-pathname-defaults* to directory around the body.

Returns the values of the form evaluated in body.

Exceptional Situations:

An error is signalled if directory is wild or has a non-null name, type, or version component.