(path: &OsPath, mode: u32, vm: &VirtualMachine)
| 325 | } |
| 326 | |
| 327 | fn win32_lchmod(path: &OsPath, mode: u32, vm: &VirtualMachine) -> PyResult<()> { |
| 328 | use windows_sys::Win32::Storage::FileSystem::{GetFileAttributesW, SetFileAttributesW}; |
| 329 | |
| 330 | let wide = path.to_wide_cstring(vm)?; |
| 331 | let attr = unsafe { GetFileAttributesW(wide.as_ptr()) }; |
| 332 | if attr == FileSystem::INVALID_FILE_ATTRIBUTES { |
| 333 | let err = io::Error::last_os_error(); |
| 334 | return Err(OSErrorBuilder::with_filename(&err, path.clone(), vm)); |
| 335 | } |
| 336 | let new_attr = if mode & S_IWRITE != 0 { |
| 337 | attr & !FileSystem::FILE_ATTRIBUTE_READONLY |
| 338 | } else { |
| 339 | attr | FileSystem::FILE_ATTRIBUTE_READONLY |
| 340 | }; |
| 341 | let ret = unsafe { SetFileAttributesW(wide.as_ptr(), new_attr) }; |
| 342 | if ret == 0 { |
| 343 | let err = io::Error::last_os_error(); |
| 344 | return Err(OSErrorBuilder::with_filename(&err, path.clone(), vm)); |
| 345 | } |
| 346 | Ok(()) |
| 347 | } |
| 348 | |
| 349 | #[pyfunction] |
| 350 | fn fchmod(fd: i32, mode: u32, vm: &VirtualMachine) -> PyResult<()> { |
no test coverage detected