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

Method is_symlink

crates/vm/src/stdlib/os.rs:737–758  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

735
736 #[pymethod]
737 fn is_symlink(&self, vm: &VirtualMachine) -> PyResult<bool> {
738 if let Ok(file_type) = &self.file_type {
739 return Ok(file_type.is_symlink());
740 }
741 #[cfg(unix)]
742 if let Some(dt) = self.d_type
743 && dt != libc::DT_UNKNOWN
744 {
745 return Ok(dt == libc::DT_LNK);
746 }
747 #[cfg(unix)]
748 return self.test_mode_via_stat(false, libc::S_IFLNK as _, vm);
749 #[cfg(not(unix))]
750 match &self.file_type {
751 Err(e) if e.kind() == io::ErrorKind::NotFound => Ok(false),
752 Err(e) => {
753 use crate::convert::ToPyException;
754 Err(e.to_pyexception(vm))
755 }
756 Ok(_) => Ok(false),
757 }
758 }
759
760 #[pymethod]
761 fn stat(

Callers 3

is_dirMethod · 0.45
is_fileMethod · 0.45
statMethod · 0.45

Calls 4

test_mode_via_statMethod · 0.80
ErrClass · 0.50
kindMethod · 0.45
to_pyexceptionMethod · 0.45

Tested by

no test coverage detected