From 1d5c5f54492cc0f5209d4b89218eaef0ab2d6208 Mon Sep 17 00:00:00 2001 From: Magic Len Date: Sun, 9 Aug 2020 07:12:54 +0800 Subject: [PATCH] fix the output path when the input path is `.` and the output path is not set --- Cargo.toml | 2 +- src/main.rs | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f4ae4a9..829a2e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xcompress" -version = "0.11.3" +version = "0.11.4" authors = ["Magic Len "] edition = "2018" repository = "https://github.com/magiclen/xcompress" diff --git a/src/main.rs b/src/main.rs index e6119f5..14abb0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -117,16 +117,15 @@ fn main() -> Result<(), Box> { let output_path = sub_matches.value_of("OUTPUT_PATH"); - let output_path = - match output_path { - Some(output_path) => Cow::from(Path::new(output_path)), - None => { - Cow::from(CWD.join(format!( - "{}.rar", - input_paths[0].file_name().unwrap().to_string_lossy() - ))) - } - }; + let output_path = match output_path { + Some(output_path) => Cow::from(Path::new(output_path)), + None => { + Cow::from(CWD.join(format!( + "{}.rar", + input_paths[0].absolutize()?.file_name().unwrap().to_string_lossy() + ))) + } + }; let best_compression = sub_matches.is_present("BEST_COMPRESSION");