You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std::os::windows::ffi::{OsStrExt,OsStringExt};
404
-
use std::ptr::null_mut;
405
-
#[link(name = "kernel32")]
406
-
extern"system"{
407
-
fnGetFullPathNameW(
408
-
lpFileName:*constu16,
409
-
nBufferLength:u32,
410
-
lpBuffer:*mutu16,
411
-
lpFilePart:*mut*constu16,
412
-
) -> u32;
413
-
}
414
-
415
-
unsafe{
416
-
// encode the path as UTF-16
417
-
let path:Vec<u16> = path.as_os_str().encode_wide().chain([0]).collect();
418
-
letmut buffer = Vec::new();
419
-
// Loop until either success or failure.
420
-
loop{
421
-
// Try to get the absolute path
422
-
let len = GetFullPathNameW(
423
-
path.as_ptr(),
424
-
buffer.len().try_into().unwrap(),
425
-
buffer.as_mut_ptr(),
426
-
null_mut(),
427
-
);
428
-
match len asusize{
429
-
// Failure
430
-
0 => returnErr(Error::last_os_error()),
431
-
// Buffer is too small, resize.
432
-
len if len > buffer.len() => buffer.resize(len,0),
433
-
// Success!
434
-
len => {
435
-
buffer.truncate(len);
436
-
returnOk(OsString::from_wide(&buffer).into());
437
-
}
438
-
}
439
-
}
440
-
}
441
-
}
442
-
443
334
/// Adapted from <https://github.com/llvm/llvm-project/blob/782e91224601e461c019e0a4573bbccc6094fbcd/llvm/cmake/modules/HandleLLVMOptions.cmake#L1058-L1079>
444
335
///
445
336
/// When `clang-cl` is used with instrumentation, we need to add clang's runtime library resource
0 commit comments