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

Function mkdir

crates/vm/src/stdlib/os.rs:341–367  ·  view source on GitHub ↗
(
        path: OsPath,
        mode: OptionalArg<i32>,
        dir_fd: DirFd<'_, { MKDIR_DIR_FD as usize }>,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

339 #[cfg(not(windows))]
340 #[pyfunction]
341 fn mkdir(
342 path: OsPath,
343 mode: OptionalArg<i32>,
344 dir_fd: DirFd<'_, { MKDIR_DIR_FD as usize }>,
345 vm: &VirtualMachine,
346 ) -> PyResult<()> {
347 let mode = mode.unwrap_or(0o777);
348 let c_path = path.clone().into_cstring(vm)?;
349 #[cfg(not(target_os = "redox"))]
350 if let Some(fd) = dir_fd.raw_opt() {
351 let res = unsafe { libc::mkdirat(fd, c_path.as_ptr(), mode as _) };
352 return if res < 0 {
353 let err = crate::common::os::errno_io_error();
354 Err(OSErrorBuilder::with_filename(&err, path, vm))
355 } else {
356 Ok(())
357 };
358 }
359 #[cfg(target_os = "redox")]
360 let [] = dir_fd.0;
361 let res = unsafe { libc::mkdir(c_path.as_ptr(), mode as _) };
362 if res < 0 {
363 let err = crate::common::os::errno_io_error();
364 return Err(OSErrorBuilder::with_filename(&err, path, vm));
365 }
366 Ok(())
367 }
368
369 #[pyfunction]
370 fn mkdirs(path: PyStrRef, vm: &VirtualMachine) -> PyResult<()> {

Callers

nothing calls this directly

Calls 6

errno_io_errorFunction · 0.85
into_cstringMethod · 0.80
raw_optMethod · 0.80
ErrClass · 0.50
cloneMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected