MCPcopy Index your code
hub / github.com/RustPython/RustPython / win32_xstat_impl

Function win32_xstat_impl

crates/vm/src/windows.rs:505–541  ·  view source on GitHub ↗
(path: &OsStr, traverse: bool)

Source from the content-addressed store, hash-verified

503}
504
505fn win32_xstat_impl(path: &OsStr, traverse: bool) -> std::io::Result<StatStruct> {
506 use windows_sys::Win32::{Foundation, Storage::FileSystem::FILE_ATTRIBUTE_REPARSE_POINT};
507
508 let stat_info =
509 get_file_information_by_name(path, FILE_INFO_BY_NAME_CLASS::FileStatBasicByNameInfo);
510 match stat_info {
511 Ok(stat_info) => {
512 if (stat_info.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT == 0)
513 || (!traverse && is_reparse_tag_name_surrogate(stat_info.ReparseTag))
514 {
515 let mut result =
516 crate::common::fileutils::windows::stat_basic_info_to_stat(&stat_info);
517 // If st_ino is 0, fall through to slow path to get proper file ID
518 if result.st_ino != 0 || result.st_ino_high != 0 {
519 result.update_st_mode_from_path(path, stat_info.FileAttributes);
520 return Ok(result);
521 }
522 }
523 }
524 Err(e) => {
525 if let Some(errno) = e.raw_os_error()
526 && matches!(
527 errno as u32,
528 Foundation::ERROR_FILE_NOT_FOUND
529 | Foundation::ERROR_PATH_NOT_FOUND
530 | Foundation::ERROR_NOT_READY
531 | Foundation::ERROR_BAD_NET_NAME
532 )
533 {
534 return Err(e);
535 }
536 }
537 }
538
539 // Fallback to slow implementation
540 win32_xstat_slow_impl(path, traverse)
541}

Callers 1

win32_xstatFunction · 0.85

Calls 6

stat_basic_info_to_statFunction · 0.85
win32_xstat_slow_implFunction · 0.85
ErrClass · 0.50

Tested by

no test coverage detected