How to use tango's FileScan correctly?
moritzwarning at web.de
Thu Oct 14 11:07:20 PDT 2010
as I've found out, FileScan is only for locating a set of files.
the preferred way is to use the virtual file system (VFS):
But I think FilePath.toList()
is enough for your plans.
On Thu, 14 Oct 2010 15:31:47 +0000, qwesx wrote:
> I'm trying out some things in D (with tango) and tried to build a *very*
> primitive indexing program. One function requires to run through a
> directory (without recursion) and get me all the files/folders in there.
> So after reading the documentation I found that tango.io.FileScan
> basically does what I need. It's just that I can't get it to work. All
> examples there use some filter, but I don't need one. And the other
> stuff I tried (and which compiled) gives me either a wrong number of
> files in my debug output, or none at all.
> Here's (part of) my code:
> FileScan scan = new FileScan();
> // only one of those was used at a time, the others are commented // dir
> is a char with an existing (absolute) directory: scan(dir, "*");
> scan(dir, ".*");
> scan(dir, "*.*");
> scan(dir, "");
> scan = scan.sweep(dir, false);
> FilePath myFolders = scan.folders(); FilePath myFiles =
> char err = scan.errors();
> Stdout("found folders: ")(myFolders.length)("\n")(); Stdout("found files
> : ")(myFiles.length)("\n")(); Stdout("errors:\n")();
> foreach (char e; err)
> The result was always:
> found folders: 0
> found files : 0
> % _
> I think I'm doing something very wrong here. And it's possibly because I
> don't understand the documentation.
> Can you help me get this to work?
More information about the Digitalmars-d-learn