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();
|
||||
if let Some(arg) = next {
|
||||
let mut output: String;
|
||||
// resolve symlinks, etc.
|
||||
// canonicalize; windows doesn't recognize symlinks
|
||||
let path = Path::new(&arg).canonicalize();
|
||||
if let Ok(target) = path {
|
||||
output = target.to_string_lossy().to_string();
|
||||
|
@ -19,12 +19,15 @@ pub fn main() {
|
|||
output = arg;
|
||||
}
|
||||
|
||||
// simple C-drive substitution
|
||||
if output.starts_with(DRIVE) {
|
||||
output = output.replace(DRIVE, "C:\\");
|
||||
}
|
||||
|
||||
// switch out separators
|
||||
output = output.replace("/", "\\");
|
||||
|
||||
// emit to stdout
|
||||
println!("{output}");
|
||||
} else {
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue