How to use tango's FileScan correctly?
Moritz Warning
moritzwarning at web.de
Thu Oct 14 11:07:20 PDT 2010
Ok,
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):
http://dsource.org/projects/tango/wiki/ChapterVFS
Examples:
http://www.dsource.org/projects/tango/wiki/VfsZipAndLinesExample
http://dsource.org/projects/tango/browser/trunk/doc/example/vfs/vfscan.d
http://dsource.org/projects/tango/browser/trunk/doc/example/vfs
But I think FilePath.toList()
is enough for your plans.
On Thu, 14 Oct 2010 15:31:47 +0000, qwesx wrote:
> Hello!
>
> 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 =
> scan.files();
> char[][] err = scan.errors();
> Stdout("found folders: ")(myFolders.length)("\n")(); Stdout("found files
> : ")(myFiles.length)("\n")(); Stdout("errors:\n")();
> foreach (char[] e; err)
> Stdout(e)("\n")();
>
>
> The result was always:
>
> found folders: 0
> found files : 0
> errors:
> % _
>
> 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?
>
>
>
> Regards
> qwesx
More information about the Digitalmars-d-learn
mailing list