comment a string hack on windows

This commit is contained in:
Folkert 2022-11-12 12:55:25 +01:00
parent d3d9320eb9
commit 9d7e1acb73
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -107,9 +107,16 @@ pub fn get_lib_path() -> Option<PathBuf> {
let exe_relative_str_path_opt = std::env::current_exe().ok();
if let Some(exe_relative_str_path) = exe_relative_str_path_opt {
// on windows, the current exe path is prefixed with `\\?\`, the "verbatim" prefix
// such a path does not works as an argument to `zig` and other command line tools,
// and there seems to be no good way to strip it. So we resort to some string manipulation
#[cfg(windows)]
let strip_windows_prefix = exe_relative_str_path.display().to_string();
#[cfg(windows)]
let exe_relative_str_path =
std::path::Path::new(strip_windows_prefix.trim_start_matches(r"\\?\"));
let mut curr_parent_opt = exe_relative_str_path.parent();
// this differs for regular build and nix releases, so we check in multiple spots.