Cannot use fs::metadata on broken link/inode, yet I need to include that entry in my listings of a file, as well as I need to get the information on that particular path, despite the fact that it is broken.
What other crate could I use to help me with that issue?
Hi and thank you for your help. Yes, it does solve the issue.
I'm curious why such split in API. Kind of unexpected that in order to get metadata of a path we need to use different function depending on the path "internal" type.
It's just mirroring Unix convention, and isn't a novel API choice on Rust's part.
Normally, if you try to open a symlink that points at the file, you want to open the file it points at. If you try to read a symlink as a directory, you want to readdir
the directory it points at. If you want to know if a path that happens to be a symlink is readable, you want to know if the thing it points at is readable. Et cetera.
Broken symlinks or needing to know you're dealing with a symlink more generally is the exception rather than the norm. If the default (following symlinks) was reversed, you'd need a different function to open a symlinked file, read a symlinked directory, and so on.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.