|
Calling Sequence
|
|
Walk(dir, traversal, opts)
|
|
Parameters
|
|
dir
|
-
|
path to the base of the directory structure to be traversed
|
traversal
|
-
|
(optional) one of the symbols topdown or bottomup
|
opts
|
-
|
(optional) arguments of the form option=value where option is one of base, followlinks, remove or select.
|
|
|
|
|
Options
|
|
•
|
base=one of bindir, datadir, homedir, mapledir, tempdir, toolboxdir, worksheetdir.
|
|
The base option specifies a base directory. If specified, the parameter dir is interpreted as a relative path under this directory. For the meaning of worksheetdir see interface; for any other of these symbols, see kernelopts.
|
|
Indicates whether the traversal will follow symbolic links and traverse the subdirectories underneath the link destination. When false, a symbolic link which points to a directory will appear in the files field of the record corresponding to its parent directory and not the subdirs field. The default value is false.
|
|
The remove option is used to remove elements from the list of filenames. Only the filenames that do not match the pattern specified in the string are returned by the iterator. The pattern must conform to the form defined by StringTools[WildcardMatch].
|
|
The select option is used to select elements from the list of filenames. Only the filenames that match the pattern specified in the string are returned by the iterator. The pattern must conform to the form defined by StringTools[WildcardMatch].
|
|
|
Description
|
|
•
|
The Walk(dir, traversal, opts) command returns an iterator object which can be used to traverse the subdirectories under the file path dir.
|
•
|
The path dir must correspond to an existing directory. It can be relative or absolute; if relative, it is interpreted as relative to the current directory as reported by currentdir.
|
•
|
With each step, the iterator object will return a record with three fields: dir, subdirs, and files.
|
|
dir is the path of a directory within the hierarchy rooted at dir,
|
|
subdirs is the list of subdirectories within dir,
|
|
files is the list of files within dir.
|
•
|
The optional parameter traversal specifies the type of traversal. Permissible values are topdown which means that the record for a directory will be returned before any of its subdirectories, or bottomup which means that the record for a directory will be generated after all of its subdirectories.
|
|
|
Iterator Objects
|
|
•
|
The iterator object is an Iterator with hasNext and getNext methods as defined by the Iterator API.
|
•
|
The state of an iterator object iter may be reset to the beginning of the iteration by invoking Reset(iter).
|
|
|
Examples
|
|
>
|
|
| (1) |
>
|
|
| |
| |
| (2) |
|
|
Compatibility
|
|
•
|
The FileTools[Walk] command was introduced in Maple 2020.
|
•
|
The FileTools[Walk] command was updated in Maple 2024.
|
•
|
The remove and select options were introduced in Maple 2024.
|
|
|
|