# Path methods — symlinks improvement

**URL:** <https://internals.rust-lang.org/t/path-methods-symlinks-improvement/14776>\
**Category:** libs\
**Created:** [May 26, 2021, 12:07pm UTC](https://internals.rust-lang.org/t/path-methods-symlinks-improvement/14776 "2021-05-26T12:07:07Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![mathstuf](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mathstuf](https://internals.rust-lang.org/u/mathstuf)\
**Post date:** [May 26, 2021, 9:42pm UTC](https://internals.rust-lang.org/t/path-methods-symlinks-improvement/14776/6 "2021-05-26T21:42:58Z")

</div>

I'd like to see `.is_symlink()` myself (though I don't have Rust code that cares right now, I do have it in other languages).

IIRC, `Path::exists()` uses `stat`, so with this, it is possible that `!broken_symlink.exists() && broken_symlink.is_symlink()` is true. So it might be a bit confusing without reading the docs (which does mention this issue at least). Though, IMO, using `stat` was a mistake, I don't think that can be fixed anymore.

See also this thread:

> [@The API of \`Path::exists()\` encourages broken code](https://internals.rust-lang.org/t/the-api-of-path-exists-encourages-broken-code/13817/1):
>
> Consider a situation in which a user wants to check existence of a file. However, the user doesn't have access to the directory that would contain the file. As a result, permission denied error happens internally but gets silently converted to false. I don't believe that "false" is the right answer to "does this file exist?" if a program is not allowed to know. I suggest to replace exists with try\_exists, which returns io::Result\<bool\> and deprecate exists. I suspect an RFC is needed for this,…

---

_[View the full topic](https://internals.rust-lang.org/t/path-methods-symlinks-improvement/14776)._
