Bug 4006 – dirEntries won't span subdirectories

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2010-03-25T19:43:00Z
Last change time
2014-02-15T02:43:20Z
Assigned to
andrei
Creator
Jesse.K.Phillips+D

Comments

Comment #0 by Jesse.K.Phillips+D — 2010-03-25T19:43:25Z
The code below creates the folders and file Hello/there/you it then checks that that string appears in on of the names returned when using dirEntries. The result is that the loop is never given that filename. ----------------------- import std.file; import std.regex; void main() { auto all = ["Hello", "Hello/there"]; foreach(dir; all) { mkdir(dir); } write(all[1] ~ "/you", "Make me feel"); assert(exists(all[1] ~ "/you"), "you don't exist"); scope(exit) { remove(all[1] ~ "/you"); foreach(dir; all) if(exists(dir)) rmdirRecurse(dir); } bool found = false; foreach(string name; dirEntries(".", SpanMode.depth)) { if(!match(name, regex(all[1] ~ "/you")).empty) found = true; } assert(found, "Missing File"); }
Comment #1 by Jesse.K.Phillips+D — 2010-03-26T10:43:12Z
I just found this Issue 2838 - std.file.rmdirRecurse fails And it mentions the problem occurs with reiserfs which I use on Linux. Though I also tested it on Windows with NTFS and the test still fails. It is likely that the issue on Linux is a duplicate of the above issue, but on Windows it may, or may not be a duplicate of the issue.
Comment #2 by dmitry.olsh — 2012-02-24T11:39:06Z
Well I know why it fails on Windows... so damn simple :) dirEntries returns paths with backslashes on Windows which is expected for this OS anywa., So, of course, regex fails to find Hello/there/you hence the assertion.
Comment #3 by dlang-bugzilla — 2012-12-21T21:20:05Z
Works on Linux in DMD 2.060. Is expected to fail on Windows per Dmitry's comment. OP did not specify platform... Closing.