(
path: OsPath,
mode: OptionalArg<i32>,
dir_fd: DirFd<'_, { MKDIR_DIR_FD as usize }>,
vm: &VirtualMachine,
)
| 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<()> { |
nothing calls this directly
no test coverage detected