Skip to content

std::io::fs::Path::is_dir incorrectly claims it returns false for links #12583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lilyball opened this issue Feb 27, 2014 · 2 comments
Closed

Comments

@lilyball
Copy link
Contributor

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.

aturon added a commit to aturon/rust that referenced this issue Apr 25, 2014
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.
bors added a commit that referenced this issue Apr 26, 2014
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.
@aturon
Copy link
Member

aturon commented Apr 28, 2014

This should be closed via PR 13750. /cc @alexcrichton

@alexcrichton
Copy link
Member

Hurray!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants