How to use tango's FileScan correctly?
Moritz Warning
moritzwarning at web.de
Thu Oct 14 09:53:44 PDT 2010
I suspect there is a bug.
You could use FilePath.toList() as an alternative for now.
foreach(path; FilePath(".").toList())
{
if(path.isFolder)
folder_counter++;
else
file_counter++;
}
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