(
name: OsPath,
flags: i32,
mode: Option<i32>,
dir_fd: DirFd<'_, { OPEN_DIR_FD as usize }>,
vm: &VirtualMachine,
)
| 243 | |
| 244 | #[cfg(any(unix, windows, target_os = "wasi"))] |
| 245 | pub(crate) fn os_open( |
| 246 | name: OsPath, |
| 247 | flags: i32, |
| 248 | mode: Option<i32>, |
| 249 | dir_fd: DirFd<'_, { OPEN_DIR_FD as usize }>, |
| 250 | vm: &VirtualMachine, |
| 251 | ) -> PyResult<crt_fd::Owned> { |
| 252 | let mode = mode.unwrap_or(0o777); |
| 253 | #[cfg(windows)] |
| 254 | let fd = { |
| 255 | let [] = dir_fd.0; |
| 256 | let name = name.to_wide_cstring(vm)?; |
| 257 | let flags = flags | libc::O_NOINHERIT; |
| 258 | crt_fd::wopen(&name, flags, mode) |
| 259 | }; |
| 260 | #[cfg(not(windows))] |
| 261 | let fd = { |
| 262 | let name = name.clone().into_cstring(vm)?; |
| 263 | #[cfg(not(target_os = "wasi"))] |
| 264 | let flags = flags | libc::O_CLOEXEC; |
| 265 | #[cfg(not(target_os = "redox"))] |
| 266 | if let Some(dir_fd) = dir_fd.get_opt() { |
| 267 | crt_fd::openat(dir_fd, &name, flags, mode) |
| 268 | } else { |
| 269 | crt_fd::open(&name, flags, mode) |
| 270 | } |
| 271 | #[cfg(target_os = "redox")] |
| 272 | { |
| 273 | let [] = dir_fd.0; |
| 274 | crt_fd::open(&name, flags, mode) |
| 275 | } |
| 276 | }; |
| 277 | fd.map_err(|err| OSErrorBuilder::with_filename_from_errno(&err, name, vm)) |
| 278 | } |
| 279 | |
| 280 | #[pyfunction] |
| 281 | fn fsync(fd: crt_fd::Borrowed<'_>) -> io::Result<()> { |
no test coverage detected