DirEntry isDir not working?

Josh moonburntm at gmail.com
Mon Feb 25 00:20:29 PST 2013


Code:
import std.file;
import std.stdio;

void main()
{
     writeln(DirEntry("F:\\").isDir());
     writeln(DirEntry("F:").isDir());
     writeln(DirEntry("F:\\folder\\").isDir());
     writeln(DirEntry("F:\\folder").isDir());
     writeln("F:\\".isDir());
     writeln("F:".isDir());
     writeln("F:\\folder\\".isDir());
     writeln("F:\\folder".isDir());
     foreach (d; dirEntries("F:\\", SpanMode.shallow))
     {
         write(d.name ~ "\t");
         writeln(d.isDir());
     }
     foreach (d; dirEntries("F:", SpanMode.shallow))
     {
         write(d.name ~ "\t");
         writeln(d.isDir());
     }
}

Output:
false
false
false
false
true
true
true
true
F:\folder       true
F:\folder       true

Is anybody able to explain why a DirEntry can't seem to detect 
whether a directory is in fact a directory, whereas plain isDir 
and even a DirEntry inside dirEntries can?

Thanks,

Josh


More information about the Digitalmars-d-learn mailing list