[Issue 3848] functions in std.file don't take symbolic links into account

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 24 08:46:32 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3848



--- Comment #2 from Jonathan M Davis <jmdavisProg at gmail.com> 2010-02-24 08:46:30 PST ---
The main problem with having isdir() and isfile() continuing to use stat, and
having the programmer just call issymlink() to check whether it's a link is
that that's a call to stat _and_ a call to lstat, and from what I understand
stat and lstat are a bit expensive (presumably because they have to talk to
disk). Of course, if there's a high chance that a programmer will have to check
whether a symlink points to a file or a directory, then they'll end up calling
both isdir()/isfile() and issymlink() and so will have a call to both stat and
lstat anyway, so it may be better to keep isdir() and isfile() using stat.
Really, it depends on the most likely use case. rmdirRecursive() is definitely
more efficient using just lstat though.

Personally, I wish that there were a function which returned information for
the file which is pointed to while telling you whether it's a symlink or not,
but unfortunately, from what I've found, there is no such beast.

>From an efficiency perspective, it would be nice if there were a function which
returned a DirEntry for a single file so that you can query that as to whether
a file is a file, dir, or symlink without calling stat or lstat every time you
call isfile(), isdir(), or issymlink(), but I couldn't figure out how to do
that, so I don't know if it can be reasonably done (since presumably it would
be silly and expensive to get the contents of the directory holding the file
just to get the DirEntry for the file itself).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list