rust/library/std
bors ff5664d600 Auto merge of #116683 - ChrisDenton:exists, r=Mark-Simulacrum
Make `try_exists` return `Ok(true)` for Windows Unix Sockets

This is a follow up to #109106 but for[ `fs::try_exists`](https://doc.rust-lang.org/std/fs/fn.try_exists.html), which doesn't need to get the metadata of a file (which can fail even if a file exists).

`fs::try_exists` currently fails on Windows if encountering a Unix Domain Socket (UDS). This PR fixes it by checking for an error code that's returned when there's a failure to use a reparse point.

## Reparse points

A reparse point is a way to invoke a filesystem filter on a file instead of the file being opened normally. This is used to implement symbolic links (by redirecting to a different path) but also to implement other types of special files such as Unix domain sockets. If the reparse point is not a link type then opening it with `CreateFileW` may fail with `ERROR_CANT_ACCESS_FILE` because the filesystem filter does not implement that operation. This differs from resolving links which may fail with errors such as `ERROR_FILE_NOT_FOUND` or `ERROR_CANT_RESOLVE_FILENAME`.

So `ERROR_CANT_ACCESS_FILE` means that the file exists but that we can't open it normally. Still, the file does exist on the filesystem so `try_exists` should report that as `Ok(true)`.

r? libs
2023-10-15 05:50:30 +00:00
..
benches
src Auto merge of #116683 - ChrisDenton:exists, r=Mark-Simulacrum 2023-10-15 05:50:30 +00:00
tests Add data race test to std::env::{get, set} 2023-08-20 21:50:45 +02:00
build.rs Revert "Invoke backtrace-rs buildscript in std buildscript" 2023-10-13 13:43:00 -06:00
Cargo.toml Revert "Invoke backtrace-rs buildscript in std buildscript" 2023-10-13 13:43:00 -06:00