FunctionPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.1
Unrevised from 8.0 to 8.1.
8.0 version

map-over-directory

Arguments: function directory &key filter prune-directories include-directories (recurse t) (file-type :pathname) (follow-symbolic-links t)

Documentation Note

In earlier releases, this documentation did not make clear that when the include-directories keyword argument is specified true, the argument directory would be one of the objects mapped over. Also, an error in the implementation (now fixed) meant that function was (incorrectly) not applied to directory when include-directories was true and file-type was :string.

This function can be used to walk a directory structure rooted at directory. function is applied to each file in the directory. directory can contain wildcards. This function is called for the side effects of applying function to files (and optionally directories) in directory. No useful value is returned.

If filter is true, then its value should be a function used to filter out candidate files and directories. The filter function takes one argument, a pathname, and returns a true value if function should be called on this file. It does not prevent recursion if the pathname is a directory.

The argument file-type controls whether a pathname object or a namestring is passed to function. The allowable values are :pathname (the default) and :string. If the directory of interest is very large, specifying :string (and ensuring that function works as desired with a string argument) may significantly reduce consing (i.e. generation of garbage).

If include-directories is true, then function also gets called on directories, including the argument directory.

If recurse is true (the default), then map-over-directory descends into subdirectories and maps over the files (or files and directories) in them. Note that this argument and include-directories are disjoint. This argument controls whether the contents of subdirectories are mapped over. include-directories controls whether directories are passed to function or not.

prune-directories, if specified, must be a list of strings naming directories with no punctuation (i.e. no slashes) or a predicate function object (not a function name, i.e. a symbol or function spec) accepting one argument of the type specified by file-type. If the value is a list, any directory encountered during the operation whose name is on the list will be ignored (neither it nor its contents nor its subdirectories will be mapped over). If the value is a predicate function, a directory for which the predicate returns true will be ignored. For example, suppose subdirectories foo and bar each have a subdirectory CVS. Then either

:prune-directories '("CVS")

or

:prune-directories '(lambda (string)
                      (if (string= "CVS" string) t))

will cause foo/CVS and bar/CVS both to be ignored (the second example assumes file-type is :string). There is no way to have foo/CVS considered and bar/CVS ignored with this argument.

The follow-symbolic-links argument determines what is done when a symbol link to a directory is encountered. If follow-symbolic-links is true, then the link is followed and all elements of the directory are acted upon. If follow-symbolic-links is nil, then the symbolic link is treated as a file, and passed to the function, but the files in the directory are not. This argument provides more control over the behavior of this function, which might be important when the function does something like deleting files. The default is t, which preserves the behavior of earlier releases.

The follow-symbolic-links argument is ignored on Windows, where there are no symbolic links.


Copyright (c) 1998-2009, Franz Inc. Oakland, CA., USA. All rights reserved.
Documentation for Allegro CL version 8.1. This page was not revised from the 8.0 page.
Created 2009.7.29.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.1
Unrevised from 8.0 to 8.1.
8.0 version