License:
BSD style: see license.txt
Version:
Jun 2004: Initial release
Version:
Dec 2006: Pacific release
author:
Kris
$(DDOC_MODULE_MEMBERS
class
FileScan
;
$(DDOC_DECL_DD 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
;
- 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));
- 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
(char[] path, bool recurse = true);
- Sweep a set of files and directories from the given parent
path, with no filtering applied
- FileScan
sweep
(char[] path, 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
(char[] path, bool delegate(FilePath, bool) 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
|