(
path: OsPath,
dir_fd: DirFd<'_, { _os::UNLINK_DIR_FD as usize }>,
vm: &VirtualMachine,
)
| 564 | #[pyfunction] |
| 565 | #[pyfunction(name = "unlink")] |
| 566 | fn remove( |
| 567 | path: OsPath, |
| 568 | dir_fd: DirFd<'_, { _os::UNLINK_DIR_FD as usize }>, |
| 569 | vm: &VirtualMachine, |
| 570 | ) -> PyResult<()> { |
| 571 | #[cfg(not(target_os = "redox"))] |
| 572 | if let Some(fd) = dir_fd.raw_opt() { |
| 573 | let c_path = path.clone().into_cstring(vm)?; |
| 574 | let res = unsafe { libc::unlinkat(fd, c_path.as_ptr(), 0) }; |
| 575 | return if res < 0 { |
| 576 | let err = crate::common::os::errno_io_error(); |
| 577 | Err(OSErrorBuilder::with_filename(&err, path, vm)) |
| 578 | } else { |
| 579 | Ok(()) |
| 580 | }; |
| 581 | } |
| 582 | #[cfg(target_os = "redox")] |
| 583 | let [] = dir_fd.0; |
| 584 | fs::remove_file(&path).map_err(|err| OSErrorBuilder::with_filename(&err, path, vm)) |
| 585 | } |
| 586 | |
| 587 | #[cfg(not(target_os = "redox"))] |
| 588 | #[pyfunction] |
nothing calls this directly
no test coverage detected