path-convert: improved clarity
This commit is contained in:
parent
9ab16d3b54
commit
13a73f701f
1 changed files with 4 additions and 1 deletions
|
@ -11,7 +11,7 @@ pub fn main() {
|
||||||
let next = args.subcommand().unwrap();
|
let next = args.subcommand().unwrap();
|
||||||
if let Some(arg) = next {
|
if let Some(arg) = next {
|
||||||
let mut output: String;
|
let mut output: String;
|
||||||
// resolve symlinks, etc.
|
// canonicalize; windows doesn't recognize symlinks
|
||||||
let path = Path::new(&arg).canonicalize();
|
let path = Path::new(&arg).canonicalize();
|
||||||
if let Ok(target) = path {
|
if let Ok(target) = path {
|
||||||
output = target.to_string_lossy().to_string();
|
output = target.to_string_lossy().to_string();
|
||||||
|
@ -19,12 +19,15 @@ pub fn main() {
|
||||||
output = arg;
|
output = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// simple C-drive substitution
|
||||||
if output.starts_with(DRIVE) {
|
if output.starts_with(DRIVE) {
|
||||||
output = output.replace(DRIVE, "C:\\");
|
output = output.replace(DRIVE, "C:\\");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// switch out separators
|
||||||
output = output.replace("/", "\\");
|
output = output.replace("/", "\\");
|
||||||
|
|
||||||
|
// emit to stdout
|
||||||
println!("{output}");
|
println!("{output}");
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue