Bug 15146 – std.file.dirEntries("") only works on Windows

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
Other
Creation time
2015-10-03T17:09:00Z
Last change time
2016-01-03T14:14:41Z
Keywords
pull
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2015-10-03T17:09:06Z
///////////////////// 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.
Comment #1 by dlang-bugzilla — 2015-10-03T17:13:20Z
Comment #2 by github-bugzilla — 2015-11-16T00:45:04Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/545bb55e769593b6fa0fede66a4440828534dbfc fix Issue 15146 - std.file.dirEntries("") only works on Windows https://github.com/D-Programming-Language/phobos/commit/32b51aed4f3726f7a14a6d4b9afde45eb94a67c7 Merge pull request #3690 from CyberShadow/pull-20151003-171210 fix Issue 15146 - std.file.dirEntries("") only works on Windows
Comment #3 by github-bugzilla — 2016-01-03T14:14:41Z