initial implementation of unix-to-dos path converter

This commit is contained in:
Valerie Wolfe 2024-05-30 09:03:46 -04:00
commit 49d76a8bc7
4 changed files with 57 additions and 0 deletions

1
path-convert/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

16
path-convert/Cargo.lock generated Normal file
View 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
View 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
View 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;
}
}
}