chickadee » posix » find-files

find-files DIRECTORY #!key test action seed limit dotfiles follow-symlinksprocedure

Recursively traverses the contents of DIRECTORY (which should be a string) and invokes the procedure action for all files in which the procedure test is true.

test may be a procedure of one argument or an irregex object, regex string or SRE expression that will be matched with a full pathname using irregex-match. test defaults to (constantly #t).

action should be a procedure of two arguments: the currently encountered file and the result of the previous invocation of action, or, if this is the first invocation, the value of seed. action defaults to cons, seed defaults to ().

limit should be a procedure of one argument that is called for each nested directory and which should return true, if that directory is to be traversed recursively. limit may also be an exact integer that gives the maximum recursion depth. For example, a depth of 0 means that only files in the top-level, specified directory are to be traversed. In this case, all nested directories are ignored. limit may also be #f (the default), which is equivalent to (constantly #t).

If dotfiles is given and true, then files starting with a "." character will not be ignored (but note that "." and ".." are always ignored). if follow-symlinks is given and true, then the traversal of a symbolic link that points to a directory will recursively traverse the latter. By default, symbolic links are not followed.

Note that action is called with the full pathname of each file, including the directory prefix.

This procedure's signature was changed in CHICKEN 4.6. In older versions, find-files has a different signature:

 (find-files DIRECTORY [TEST [ACTION [SEED [LIMIT]]]])

The old signature was supported until CHICKEN 4.7.3 for compatibility reasons, at which point it became invalid. The optional arguments are ignored and use their default values, and no warning is issued. One symptom is that your TEST does not work, returning every file.