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

Method stat_dir_fd

crates/vm/src/stdlib/os.rs:651–660  ·  view source on GitHub ↗

Build the DirFd to use for stat calls. If this entry was produced by fd-based scandir, use the stored dir_fd so that fstatat(dir_fd, name, ...) is used instead of stat(full_path).

(&self)

Source from the content-addressed store, hash-verified

649 /// If this entry was produced by fd-based scandir, use the stored dir_fd
650 /// so that fstatat(dir_fd, name, ...) is used instead of stat(full_path).
651 fn stat_dir_fd(&self) -> DirFd<'_, { STAT_DIR_FD as usize }> {
652 #[cfg(not(any(windows, target_os = "redox")))]
653 if let Some(raw_fd) = self.dir_fd {
654 // Safety: the fd came from os.open() and is borrowed for
655 // the lifetime of this DirEntry reference.
656 let borrowed = unsafe { crt_fd::Borrowed::borrow_raw(raw_fd) };
657 return DirFd([borrowed; STAT_DIR_FD as usize]);
658 }
659 DirFd::default()
660 }
661
662 /// Stat-based mode test fallback. Uses fstatat when dir_fd is available.
663 #[cfg(unix)]

Callers 2

test_mode_via_statMethod · 0.80
statMethod · 0.80

Calls 1

DirFdClass · 0.85

Tested by 1

test_mode_via_statMethod · 0.64