forked from extern/nushell
Try not to use verbatim paths for UNC shares (#6824)
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
#[cfg(windows)]
|
||||
use omnipath::WinPathExt;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn home_dir() -> Option<PathBuf> {
|
||||
@ -7,3 +9,22 @@ pub fn home_dir() -> Option<PathBuf> {
|
||||
pub fn config_dir() -> Option<PathBuf> {
|
||||
dirs_next::config_dir()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn canonicalize(path: &std::path::Path) -> std::io::Result<std::path::PathBuf> {
|
||||
path.canonicalize()?.to_winuser_path()
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
pub fn canonicalize(path: &std::path::Path) -> std::io::Result<std::path::PathBuf> {
|
||||
path.canonicalize()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn simiplified(path: &std::path::Path) -> PathBuf {
|
||||
path.to_winuser_path()
|
||||
.unwrap_or_else(|_| path.to_path_buf())
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
pub fn simiplified(path: &std::path::Path) -> PathBuf {
|
||||
path.to_path_buf()
|
||||
}
|
||||
|
Reference in New Issue
Block a user