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)
| 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)] |