mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 12:05:46 +00:00
Ask to overwrite if the user specified dir exists
This commit is contained in:
parent
85968ea841
commit
11ee27ea25
@ -203,10 +203,16 @@ pub fn run(args: Opts, question_policy: QuestionPolicy) -> crate::Result<()> {
|
|||||||
|
|
||||||
// The directory that will contain the output files
|
// The directory that will contain the output files
|
||||||
// We default to the current directory if the user didn't specify an output directory with --dir
|
// We default to the current directory if the user didn't specify an output directory with --dir
|
||||||
let output_dir = output_dir.unwrap_or_else(|| PathBuf::from("."));
|
let output_dir = if let Some(dir) = output_dir {
|
||||||
// NOTE: If the user *did* use --dir and the directory already exists, we will merge the
|
if !utils::clear_path(&dir, question_policy)? {
|
||||||
// extracted filed inside it
|
// User doesn't want to overwrite
|
||||||
utils::create_dir_if_non_existent(&output_dir)?;
|
return Ok(());
|
||||||
|
}
|
||||||
|
utils::create_dir_if_non_existent(&dir)?;
|
||||||
|
dir
|
||||||
|
} else {
|
||||||
|
PathBuf::from(".")
|
||||||
|
};
|
||||||
|
|
||||||
for ((input_path, formats), file_name) in files.iter().zip(formats).zip(output_paths) {
|
for ((input_path, formats), file_name) in files.iter().zip(formats).zip(output_paths) {
|
||||||
let output_file_path = output_dir.join(file_name); // Path used by single file format archives
|
let output_file_path = output_dir.join(file_name); // Path used by single file format archives
|
||||||
|
Loading…
x
Reference in New Issue
Block a user