[Issue 20109] DirEntries() fails on symbolic links to non-existent file
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Aug 6 06:11:15 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20109
shove <shove at 163.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |shove at 163.com
--- Comment #1 from shove <shove at 163.com> ---
I don't think there is any problem here. It is correct to throw an exception to
a non-existent file getSize.
When traversing files, folders and symlinks, we should judge them and decide
whether to do some operations.
import std.file;
import std.stdio;
string path = "...";
foreach (DirEntry e; dirEntries(path, SpanMode.shallow))
{
if (e.isSymlink)
{
string origin = readLink(e.name);
if (origin.exists)
writeln(origin, ", size: ", e.size);
else
writeln(origin, " not exists. ");
}
}
--
More information about the Digitalmars-d-bugs
mailing list