(path: OsPath, vm: &VirtualMachine)
| 1374 | |
| 1375 | #[pyfunction] |
| 1376 | fn _getvolumepathname(path: OsPath, vm: &VirtualMachine) -> PyResult { |
| 1377 | let wide = path.to_wide_cstring(vm)?; |
| 1378 | let buflen = core::cmp::max(wide.len(), Foundation::MAX_PATH as usize); |
| 1379 | if buflen > u32::MAX as usize { |
| 1380 | return Err(vm.new_overflow_error("path too long")); |
| 1381 | } |
| 1382 | let mut buffer = vec![0u16; buflen]; |
| 1383 | let ret = unsafe { |
| 1384 | FileSystem::GetVolumePathNameW(wide.as_ptr(), buffer.as_mut_ptr(), buflen as _) |
| 1385 | }; |
| 1386 | if ret == 0 { |
| 1387 | let err = io::Error::last_os_error(); |
| 1388 | return Err(OSErrorBuilder::with_filename(&err, path, vm)); |
| 1389 | } |
| 1390 | let buffer = widestring::WideCString::from_vec_truncate(buffer); |
| 1391 | Ok(path.mode().process_path(buffer.to_os_string(), vm)) |
| 1392 | } |
| 1393 | |
| 1394 | /// Implements _Py_skiproot logic for Windows paths |
| 1395 | /// Returns (drive_size, root_size) where: |
no test coverage detected