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

Method is_dir

crates/vm/src/stdlib/os.rs:687–709  ·  view source on GitHub ↗
(&self, follow_symlinks: FollowSymlinks, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

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> {

Callers 6

process_python_libsFunction · 0.45
load_client_ca_listFunction · 0.45
search_up_dirFunction · 0.45
calculate_stdlib_dirFunction · 0.45
compile_dirMethod · 0.45

Calls 6

fs_metadataFunction · 0.85
test_mode_via_statMethod · 0.80
ErrClass · 0.50
is_symlinkMethod · 0.45
kindMethod · 0.45
into_pyexceptionMethod · 0.45

Tested by

no test coverage detected