Rollup merge of #109235 - chaitanyav:master, r=ChrisDenton

fallback to lstat when stat fails on Windows

Fixes #109106
````@ChrisDenton```` please let me know if this is the expected behavior for stat on windows
This commit is contained in:
Matthias Krüger 2023-03-18 00:05:53 +01:00 committed by GitHub
commit 2a3c0e34cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1236,7 +1236,17 @@ pub fn link(_original: &Path, _link: &Path) -> io::Result<()> {
}
pub fn stat(path: &Path) -> io::Result<FileAttr> {
metadata(path, ReparsePoint::Follow)
match metadata(path, ReparsePoint::Follow) {
Err(err) if err.raw_os_error() == Some(c::ERROR_CANT_ACCESS_FILE as i32) => {
if let Ok(attrs) = lstat(path) {
if !attrs.file_type().is_symlink() {
return Ok(attrs);
}
}
Err(err)
}
result => result,
}
}
pub fn lstat(path: &Path) -> io::Result<FileAttr> {