(&self, follow_symlinks: FollowSymlinks, vm: &VirtualMachine)
| 710 | |
| 711 | #[pymethod] |
| 712 | fn is_file(&self, follow_symlinks: FollowSymlinks, vm: &VirtualMachine) -> PyResult<bool> { |
| 713 | if let Ok(file_type) = &self.file_type |
| 714 | && (!follow_symlinks.0 || !file_type.is_symlink()) |
| 715 | { |
| 716 | return Ok(file_type.is_file()); |
| 717 | } |
| 718 | #[cfg(unix)] |
| 719 | if let Some(dt) = self.d_type { |
| 720 | let is_symlink = dt == libc::DT_LNK; |
| 721 | let need_stat = dt == libc::DT_UNKNOWN || (follow_symlinks.0 && is_symlink); |
| 722 | if !need_stat { |
| 723 | return Ok(dt == libc::DT_REG); |
| 724 | } |
| 725 | } |
| 726 | #[cfg(unix)] |
| 727 | return self.test_mode_via_stat(follow_symlinks.0, libc::S_IFREG as _, vm); |
| 728 | #[cfg(not(unix))] |
| 729 | match super::fs_metadata(&self.pathval, follow_symlinks.0) { |
| 730 | Ok(meta) => Ok(meta.is_file()), |
| 731 | Err(e) if e.kind() == io::ErrorKind::NotFound => Ok(false), |
| 732 | Err(e) => Err(e.into_pyexception(vm)), |
| 733 | } |
| 734 | } |
| 735 | |
| 736 | #[pymethod] |
| 737 | fn is_symlink(&self, vm: &VirtualMachine) -> PyResult<bool> { |
no test coverage detected