mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 12:05:46 +00:00
use remove_file_or_dir to remove dir check
This commit is contained in:
parent
6e6796bf4e
commit
9f7cba79e1
@ -15,7 +15,7 @@ use super::{strip_cur_dir, to_utf};
|
|||||||
use crate::{
|
use crate::{
|
||||||
accessible::is_running_in_accessible_mode,
|
accessible::is_running_in_accessible_mode,
|
||||||
error::{Error, Result},
|
error::{Error, Result},
|
||||||
utils::colors,
|
utils::{self, colors},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
@ -59,9 +59,7 @@ pub fn ask_to_create_file(path: &Path, question_policy: QuestionPolicy) -> Resul
|
|||||||
Ok(w) => Ok(Some(w)),
|
Ok(w) => Ok(Some(w)),
|
||||||
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {
|
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {
|
||||||
if user_wants_to_overwrite(path, question_policy)? {
|
if user_wants_to_overwrite(path, question_policy)? {
|
||||||
if path.is_dir() {
|
utils::remove_file_or_dir(path)?;
|
||||||
fs::remove_dir_all(path)?;
|
|
||||||
}
|
|
||||||
Ok(Some(fs::File::create(path)?))
|
Ok(Some(fs::File::create(path)?))
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user