initial implementation of unix-to-dos path converter
This commit is contained in:
commit
49d76a8bc7
4 changed files with 57 additions and 0 deletions
1
path-convert/.gitignore
vendored
Normal file
1
path-convert/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target
|
16
path-convert/Cargo.lock
generated
Normal file
16
path-convert/Cargo.lock
generated
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "path-convert"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"pico-args",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pico-args"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315"
|
16
path-convert/Cargo.toml
Normal file
16
path-convert/Cargo.toml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
[package]
|
||||||
|
name = "path-convert"
|
||||||
|
version = "0.0.1"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
pico-args = "0.5.0"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
opt-level = 's'
|
||||||
|
codegen-units = 1
|
||||||
|
debug = false
|
||||||
|
lto = true
|
||||||
|
panic = "abort"
|
||||||
|
strip = "symbols"
|
||||||
|
|
24
path-convert/src/main.rs
Normal file
24
path-convert/src/main.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
use pico_args::Arguments;
|
||||||
|
|
||||||
|
const DRIVE: &str = "/mnt/c/";
|
||||||
|
|
||||||
|
pub fn main() {
|
||||||
|
let mut args = Arguments::from_env();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let next = args.subcommand().unwrap();
|
||||||
|
if let Some(mut arg) = next {
|
||||||
|
if arg.starts_with(DRIVE) {
|
||||||
|
arg = arg.replace(DRIVE, "C:\\");
|
||||||
|
}
|
||||||
|
arg = arg.replace("/", "\\");
|
||||||
|
println!("{arg}");
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue