MCPcopy Index your code
hub / github.com/RustPython/RustPython / _getfullpathname

Function _getfullpathname

crates/vm/src/stdlib/nt.rs:1341–1373  ·  view source on GitHub ↗
(path: OsPath, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1339
1340 #[pyfunction]
1341 fn _getfullpathname(path: OsPath, vm: &VirtualMachine) -> PyResult {
1342 let wpath = path.to_wide_cstring(vm)?;
1343 let mut buffer = vec![0u16; Foundation::MAX_PATH as usize];
1344 let ret = unsafe {
1345 FileSystem::GetFullPathNameW(
1346 wpath.as_ptr(),
1347 buffer.len() as _,
1348 buffer.as_mut_ptr(),
1349 core::ptr::null_mut(),
1350 )
1351 };
1352 if ret == 0 {
1353 let err = io::Error::last_os_error();
1354 return Err(OSErrorBuilder::with_filename(&err, path.clone(), vm));
1355 }
1356 if ret as usize > buffer.len() {
1357 buffer.resize(ret as usize, 0);
1358 let ret = unsafe {
1359 FileSystem::GetFullPathNameW(
1360 wpath.as_ptr(),
1361 buffer.len() as _,
1362 buffer.as_mut_ptr(),
1363 core::ptr::null_mut(),
1364 )
1365 };
1366 if ret == 0 {
1367 let err = io::Error::last_os_error();
1368 return Err(OSErrorBuilder::with_filename(&err, path.clone(), vm));
1369 }
1370 }
1371 let buffer = widestring::WideCString::from_vec_truncate(buffer);
1372 Ok(path.mode().process_path(buffer.to_os_string(), vm))
1373 }
1374
1375 #[pyfunction]
1376 fn _getvolumepathname(path: OsPath, vm: &VirtualMachine) -> PyResult {

Callers 1

abspathFunction · 0.90

Calls 9

as_mut_ptrMethod · 0.80
process_pathMethod · 0.80
ErrClass · 0.50
to_wide_cstringMethod · 0.45
as_ptrMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45
resizeMethod · 0.45
modeMethod · 0.45

Tested by

no test coverage detected