(&self, follow_symlinks: FollowSymlinks, vm: &VirtualMachine)
| 685 | |
| 686 | #[pymethod] |
| 687 | fn is_dir(&self, follow_symlinks: FollowSymlinks, vm: &VirtualMachine) -> PyResult<bool> { |
| 688 | if let Ok(file_type) = &self.file_type |
| 689 | && (!follow_symlinks.0 || !file_type.is_symlink()) |
| 690 | { |
| 691 | return Ok(file_type.is_dir()); |
| 692 | } |
| 693 | #[cfg(unix)] |
| 694 | if let Some(dt) = self.d_type { |
| 695 | let is_symlink = dt == libc::DT_LNK; |
| 696 | let need_stat = dt == libc::DT_UNKNOWN || (follow_symlinks.0 && is_symlink); |
| 697 | if !need_stat { |
| 698 | return Ok(dt == libc::DT_DIR); |
| 699 | } |
| 700 | } |
| 701 | #[cfg(unix)] |
| 702 | return self.test_mode_via_stat(follow_symlinks.0, libc::S_IFDIR as _, vm); |
| 703 | #[cfg(not(unix))] |
| 704 | match super::fs_metadata(&self.pathval, follow_symlinks.0) { |
| 705 | Ok(meta) => Ok(meta.is_dir()), |
| 706 | Err(e) if e.kind() == io::ErrorKind::NotFound => Ok(false), |
| 707 | Err(e) => Err(e.into_pyexception(vm)), |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | #[pymethod] |
| 712 | fn is_file(&self, follow_symlinks: FollowSymlinks, vm: &VirtualMachine) -> PyResult<bool> { |
no test coverage detected