Skip to content

Commit 1d5c5f5

Browse files
committed
fix the output path when the input path is . and the output path is not set
1 parent 64a437b commit 1d5c5f5

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "xcompress"
3-
version = "0.11.3"
3+
version = "0.11.4"
44
authors = ["Magic Len <[email protected]>"]
55
edition = "2018"
66
repository = "https://github.com/magiclen/xcompress"

src/main.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,15 @@ fn main() -> Result<(), Box<dyn Error>> {
117117

118118
let output_path = sub_matches.value_of("OUTPUT_PATH");
119119

120-
let output_path =
121-
match output_path {
122-
Some(output_path) => Cow::from(Path::new(output_path)),
123-
None => {
124-
Cow::from(CWD.join(format!(
125-
"{}.rar",
126-
input_paths[0].file_name().unwrap().to_string_lossy()
127-
)))
128-
}
129-
};
120+
let output_path = match output_path {
121+
Some(output_path) => Cow::from(Path::new(output_path)),
122+
None => {
123+
Cow::from(CWD.join(format!(
124+
"{}.rar",
125+
input_paths[0].absolutize()?.file_name().unwrap().to_string_lossy()
126+
)))
127+
}
128+
};
130129

131130
let best_compression = sub_matches.is_present("BEST_COMPRESSION");
132131

0 commit comments

Comments
 (0)