commit 49d76a8bc7cceec0b5d7f2c144c56c3fbd517c21 Author: Valerie Wolfe Date: Thu May 30 09:03:46 2024 -0400 initial implementation of unix-to-dos path converter diff --git a/path-convert/.gitignore b/path-convert/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/path-convert/.gitignore @@ -0,0 +1 @@ +/target diff --git a/path-convert/Cargo.lock b/path-convert/Cargo.lock new file mode 100644 index 0000000..fea3fcb --- /dev/null +++ b/path-convert/Cargo.lock @@ -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" diff --git a/path-convert/Cargo.toml b/path-convert/Cargo.toml new file mode 100644 index 0000000..006cefc --- /dev/null +++ b/path-convert/Cargo.toml @@ -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" + diff --git a/path-convert/src/main.rs b/path-convert/src/main.rs new file mode 100644 index 0000000..4e124b0 --- /dev/null +++ b/path-convert/src/main.rs @@ -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; + } + } + +} + +