You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for is_dir in the Path impl in std::io::fs incorrectly claims that it returns false for links. It's actually implemented using stat(), which means that it will test the pointed-to file for a link.
Furthermore, .is_file() doesn't even document whether it tries to look through links.
I expect both of these files should be using stat(), so their implementations are correct, but the documentation needs to be updated to explicitly state that it will test the pointed-to file for a link.
While we're at it, .exists() says it "will return true if the path points to either a directory or a file". This can be expected to be read as "regular file", but it returns true for all file kinds, not just directories and regular files. Specifically, it just tests if stat() returns true. Incidentally, this means it will in fact return false if the path represents a symlink that does exist but points to a path that doesn't. This should also be documented.
Also, as long as we're exposing a .stat() convenience here, we should probably expose an .lstat() convenience method as well.
And finally, these methods all reference conditions (specifically, saying they don't raise conditions). That bit needs to be deleted outright.
The text was updated successfully, but these errors were encountered:
Clarifies the interaction of `is_dir`, `is_file` and `exists` with
symbolic links. Adds a convenience `lstat` function alongside of
`stat`. Removes references to conditions.
Closes issue rust-lang#12583.
Clarifies the interaction of `is_dir`, `is_file` and `exists` with
symbolic links. Adds a convenience `lstat` function alongside of
`stat`. Removes references to conditions.
Closes issue #12583.
The documentation for
is_dir
in thePath
impl instd::io::fs
incorrectly claims that it returnsfalse
for links. It's actually implemented usingstat()
, which means that it will test the pointed-to file for a link.Furthermore,
.is_file()
doesn't even document whether it tries to look through links.I expect both of these files should be using
stat()
, so their implementations are correct, but the documentation needs to be updated to explicitly state that it will test the pointed-to file for a link.While we're at it,
.exists()
says it "will return true if the path points to either a directory or a file". This can be expected to be read as "regular file", but it returnstrue
for all file kinds, not just directories and regular files. Specifically, it just tests ifstat()
returnstrue
. Incidentally, this means it will in fact returnfalse
if the path represents a symlink that does exist but points to a path that doesn't. This should also be documented.Also, as long as we're exposing a
.stat()
convenience here, we should probably expose an.lstat()
convenience method as well.And finally, these methods all reference conditions (specifically, saying they don't raise conditions). That bit needs to be deleted outright.
The text was updated successfully, but these errors were encountered: