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

Function symlink

crates/vm/src/stdlib/posix.rs:544–562  ·  view source on GitHub ↗
(args: SymlinkArgs<'_>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

542
543 #[pyfunction]
544 pub(super) fn symlink(args: SymlinkArgs<'_>, vm: &VirtualMachine) -> PyResult<()> {
545 let src = args.src.into_cstring(vm)?;
546 let dst = args.dst.into_cstring(vm)?;
547 #[cfg(not(target_os = "redox"))]
548 {
549 nix::unistd::symlinkat(&*src, args.dir_fd.get(), &*dst)
550 .map_err(|err| err.into_pyexception(vm))
551 }
552 #[cfg(target_os = "redox")]
553 {
554 let [] = args.dir_fd.0;
555 let res = unsafe { libc::symlink(src.as_ptr(), dst.as_ptr()) };
556 if res < 0 {
557 Err(vm.new_last_errno_error())
558 } else {
559 Ok(())
560 }
561 }
562 }
563
564 #[pyfunction]
565 #[pyfunction(name = "unlink")]

Callers

nothing calls this directly

Calls 6

into_cstringMethod · 0.80
new_last_errno_errorMethod · 0.80
ErrClass · 0.50
getMethod · 0.45
into_pyexceptionMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected