mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-05 07:27:46 +00:00
fix uucore::fs for windows
- standardize the return value of `std::env::current_dir()` by using `canonicalize()` .# [why] `std::env::current_dir()` will, in some situations on windows hosts, return "short"-type paths (eg, "C:\Progra~1\..."). Using `canonicalize()` transforms the path in a standard long form but may also require removing a leading "\\?\" prefix.
This commit is contained in:
parent
2792d85865
commit
667ed39ece
2 changed files with 4 additions and 2 deletions
|
@ -16,6 +16,7 @@ travis-ci = { repository = "uutils/uucore" }
|
||||||
appveyor = { repository = "uutils/uucore" }
|
appveyor = { repository = "uutils/uucore" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
dunce = "1.0.0"
|
||||||
getopts = "0.2.18"
|
getopts = "0.2.18"
|
||||||
failure = { version = "0.1.1", optional = true }
|
failure = { version = "0.1.1", optional = true }
|
||||||
failure_derive = { version = "0.1.1", optional = true }
|
failure_derive = { version = "0.1.1", optional = true }
|
||||||
|
@ -43,4 +44,3 @@ entries = ["libc"]
|
||||||
zero-copy = ["nix", "libc", "lazy_static", "platform-info"]
|
zero-copy = ["nix", "libc", "lazy_static", "platform-info"]
|
||||||
wide = []
|
wide = []
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
extern crate dunce;
|
||||||
#[cfg(target_os = "redox")]
|
#[cfg(target_os = "redox")]
|
||||||
extern crate termion;
|
extern crate termion;
|
||||||
|
|
||||||
|
@ -101,7 +103,7 @@ pub fn canonicalize<P: AsRef<Path>>(original: P, can_mode: CanonicalizeMode) ->
|
||||||
let original = if original.is_absolute() {
|
let original = if original.is_absolute() {
|
||||||
original.to_path_buf()
|
original.to_path_buf()
|
||||||
} else {
|
} else {
|
||||||
env::current_dir().unwrap().join(original)
|
dunce::canonicalize(env::current_dir().unwrap()).unwrap().join(original)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut result = PathBuf::new();
|
let mut result = PathBuf::new();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue