This function returns a list of files whose names match the specified
globbing patterns. A globbing pattern is one in which '?' matches a
single character, and '*' matches 0 or more characters.
The fswalk_new function creates an object that is useful
for exploring a filesystem tree. It requires two arguments that
are references to functions to be called when a directory or file is
encountered. Each of these functions is passed at least two
arguments: the name of the file or directory (including leading path
elements relative to the directory where processing started), and
the stat structure of the of the file or directory. Qualifiers may
be used to specify additional arguments.
The object's walk method is the one that actually walks the
filesystem.
The directory callback function must return an integer value that
indicates how it should be processed. If the function returns 0,
then the directory will be skipped (pruned). A positive value
indicates that the directory will processed. If the function
returns a negative value, then no further processing by the walk
function will take place and control will pass to the user.
The file callback function must also return an integer that
indicates how processing should continue. If it returns a positive
value, then additional files in the corresponding directory will be
processed. If it returns 0, then no further files or subdirectories
of the directory will be processed, and processing will continue to
take place in the parent directory. Otherwise, the return value is
negative, which indicates that processing should be stopped and
control will pass back to the caller.
Qualifiers
The following qualifiers are supported:
dargs={args...}
dargs is a list of additional arguments that will be added when
calling the directory callback function.
fargs={args...}
fargs is a list of additional arguments that will be added when
calling the file callback function.
followlinks[=val]
The followlinks qualifier may be used to indicate whether
or not directories that are symbolic links are to be followed. By
default, they are not. If followlinks is present with no
value, or has a non-zero value, then symbolic links will be
followed. Otherwise, if followlinks is not present, or is
set to 0, then directories that are symbolic links will be skipped.
Methods
.walk (String_Type top_dir)
The .walk function walks the filesystem starting at the
specified top-level directory calling the directory and file
callback functions as it goes.
Example
Print a list of all files containing a .png extension under
the current directory:
Note that in this example, the dir_callback function returns 0 if
the directory corresponds to a symbolic link. This causes the link
to not be followed.