tango.io.FileScan

License:

BSD style: see license.txt

Version:

Jun 2004: Initial release

Version:

Dec 2006: Pacific release

Author:

Kris
class FileScan [deprecated]
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:
1
2
3
4
5
6
7
8
9
10
11
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 FilePath.Filter 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:
1
return (isDir || match (fp.name));
const(char)[][] errors() [public]
Return all the errors found in the last scan
FilePath[] files() [public]
Return all the files found in the last scan
FilePath[] folders() [public]
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