diff options
| author | alesito85 <grm.ales@gmail.com> | 2023-02-13 03:57:22 -0500 |
|---|---|---|
| committer | alesito85 <grm.ales@gmail.com> | 2023-02-13 11:50:25 +0100 |
| commit | f72eb4704a944c75c1eb1215bce6961fae3b3608 (patch) | |
| tree | 8d60704b92d2c9957c83056a0b8a3b6d6c29aa6a /library/std/src | |
| parent | 96834f0231277e8feb8dcf185b2af082ad2e39f6 (diff) | |
| download | rust-f72eb4704a944c75c1eb1215bce6961fae3b3608.tar.gz rust-f72eb4704a944c75c1eb1215bce6961fae3b3608.zip | |
Add another error to Windows file open fallback
Added another error to be processed in fallback Solution suggested by Chris Denton https://github.com/nushell/nushell/issues/6857#issuecomment-1426847135
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys/windows/fs.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/library/std/src/sys/windows/fs.rs b/library/std/src/sys/windows/fs.rs index f1a784b5fd2..d2c597664fa 100644 --- a/library/std/src/sys/windows/fs.rs +++ b/library/std/src/sys/windows/fs.rs @@ -1266,7 +1266,12 @@ fn metadata(path: &Path, reparse: ReparsePoint) -> io::Result<FileAttr> { // If the fallback fails for any reason we return the original error. match File::open(path, &opts) { Ok(file) => file.file_attr(), - Err(e) if e.raw_os_error() == Some(c::ERROR_SHARING_VIOLATION as _) => { + Err(e) + if [Some(c::ERROR_SHARING_VIOLATION as _), Some(c::ERROR_ACCESS_DENIED as _)] + .contains(&e.raw_os_error()) => + { + // `ERROR_ACCESS_DENIED` is returned when the user doesn't have permission for the resource. + // One such example is `System Volume Information` as default but can be created as well // `ERROR_SHARING_VIOLATION` will almost never be returned. // Usually if a file is locked you can still read some metadata. // However, there are special system files, such as |
