[Issue 15146] New: std.file.dirEntries("") only works on Windows
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Sat Oct  3 10:09:06 PDT 2015
    
    
  
https://issues.dlang.org/show_bug.cgi?id=15146
          Issue ID: 15146
           Summary: std.file.dirEntries("") only works on Windows
           Product: D
           Version: D2
          Hardware: All
                OS: Other
            Status: NEW
          Severity: enhancement
          Priority: P4
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: thecybershadow at gmail.com
///////////////////// test.d /////////////////////
import std.algorithm.iteration;
import std.file;
import std.stdio;
void main()
{
    dirEntries("", SpanMode.shallow).each!writeln;
}
//////////////////////////////////////////////////
This program runs fine on Windows, but throws on POSIX.
This is because POSIX opendir is defined to return ENOENT if the argument is an
empty string:
> [ENOENT] A component of dirname does not name an existing directory or dirname is an empty string.
Although the call to dirEntries can be changed to dirEntries("."), this has the
unpleasant effect of prepending "./" to all paths returned by dirEntries. It is
additionally a portability hazard (code that works on one OS but not another).
I thus propose to make dirEntries("") call opendir(".") under the hood.
--
    
    
More information about the Digitalmars-d-bugs
mailing list