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: [email protected]
Reporter: [email protected]
///////////////////// 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.
--