summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzjp <jiping_zhou@foxmail.com>2023-05-13 22:44:13 +0800
committerDenis Isidoro <denis.isidoro@uber.com>2023-12-10 06:26:34 -0300
commitaeb9cd4b8baf80cb19a2de31c634437c847ea236 (patch)
treefd4ea3823b6baa98cb647f2eb9e95b4834b566a3
parent6a0accface7e0abcfd91184ea13726b15e432dbc (diff)
Fix preview: handle Windows NT UNC paths (`\\?\C:\foo`)
-rw-r--r--Cargo.lock7
-rw-r--r--Cargo.toml3
-rw-r--r--src/common/fs.rs5
3 files changed, 15 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ac4c0ef..a379f1b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -245,6 +245,12 @@ dependencies = [
]
[[package]]
+name = "dunce"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b"
+
+[[package]]
name = "edit"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -455,6 +461,7 @@ dependencies = [
"crossterm",
"dns_common",
"dns_common_derive",
+ "dunce",
"edit",
"etcetera",
"lazy_static",
diff --git a/Cargo.toml b/Cargo.toml
index a9dc3d1..fa054cc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -37,6 +37,9 @@ dns_common_derive = { version = "0.2.1" }
dns_common = { version = "0.2.1", default-features = false, features = ["yaml", "json"] }
unicode-width = "0.1.10"
+[target.'cfg(windows)'.dependencies]
+dunce = "1"
+
[lib]
name = "navi"
path = "src/lib.rs"
diff --git a/src/common/fs.rs b/src/common/fs.rs
index 32c8b1e..cf8a737 100644
--- a/src/common/fs.rs
+++ b/src/common/fs.rs
@@ -78,6 +78,11 @@ fn follow_symlink(pathbuf: PathBuf) -> Result<PathBuf> {
fn exe_pathbuf() -> Result<PathBuf> {
let pathbuf = std::env::current_exe().context("Unable to acquire executable's path")?;
+
+ #[cfg(target_family = "windows")]
+ let pathbuf = dunce::canonicalize(pathbuf)?;
+
+ debug!(current_exe = ?pathbuf);
follow_symlink(pathbuf)
}