[Issue 6138] Using dirEntries and chdir() can have unwanted results
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jan 29 13:14:54 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=6138
Francesco Galla' <francesco.galla3 at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |francesco.galla3 at gmail.com
--- Comment #5 from Francesco Galla' <francesco.galla3 at gmail.com> ---
(In reply to RazvanN from comment #3)
> After analyzing the code I see that dirEntries does not call absolutePath on
> the path, which in my opinion is a bug. Even though I cannot reproduce the
> bug, I think a call to absolutePath should definitely be added
I reproduced the bug with the following code:
foreach (string entry; dirEntries((dir), SpanMode.shallow))
{
if (entry.isDir)
{
foreach (string subentry; dirEntries(entry, SpanMode.shallow))
{
if (subentry.isDir)
{
chdir(absolutePath(subentry));
writeln (absolutePath(subentry));
}
}
}
}
My directory tree is:
.
├── 1
│ └── 2
├── 3
│ ├── 4
│ └── 5
│ └── 6
* The result I obtained was the following:
std.file.FileException@/opt/dmd-2.075/import/std/file.d(1631): ./3: No such
file or directory
* By calling:
foreach (string entry; dirEntries(absolutePath(dir), SpanMode.shallow))
The code was executed correctly. This seems to confirm the need for
dirEntries() to call absolutePath(). Am I mistaken?
--
More information about the Digitalmars-d-bugs
mailing list