This module is deprecated because it doesn't support file globbing
or regexes for matching files and because it ignores folders that
it doesn't recurse into (a non-recursive scan will never return any
folders).
Recursively scan files and directories, adding filtered files to
an output structure as we go. This can be used to produce a list
of subdirectories and the files contained therein. The following
example lists all files with suffix ".d" located via the current
directory, along with the folders containing them:
auto scan = new FileScan;
scan (".", ".d");
Stdout.formatln ("{} Folders", scan.folders.length);
foreach (folder; scan.folders)
Stdout.formatln ("{}", folder);
Stdout.formatln ("\n{} Files", scan.files.length);
foreach (file; scan.files)
Stdout.formatln ("{}", file);
This is unlikely the most efficient method to scan a vast number of
files, but operates in a convenient manner.
- alias Filter = bool delegate(FilePath, bool);
- Alias for Filter delegate. Accepts a FilePath & a bool as
arguments and returns a bool.
The FilePath argument represents a file found by the scan,
and the bool whether the FilePath represents a folder.
The filter should return true, if matched by the filter. Note
that returning false where the path is a folder will result
in all files contained being ignored. To always recurse folders,
do something like this:
return (isDir || match (fp.name));
- const(char)[][] errors();
- Return all the errors found in the last scan
- FilePath[] files();
- Return all the files found in the last scan
- FilePath[] folders();
- Return all directories found in the last scan
- FileScan sweep(const(char)[] path, bool recurse = true);
- Sweep a set of files and directories from the given parent
path, with no filtering applied
- FileScan sweep(const(char)[] path, const(char)[] match, bool recurse = true);
- Sweep a set of files and directories from the given parent
path, where the files are filtered by the given suffix
- FileScan sweep(const(char)[] path, Filter filter, bool recurse = true);
- Sweep a set of files and directories from the given parent
path, where the files are filtered by the provided delegate