mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 20:15:27 +00:00
create remove_file_or_dir util
This commit is contained in:
parent
f5fc7bd755
commit
4d2ccf4873
@ -29,13 +29,18 @@ pub fn clear_path(path: &Path, question_policy: QuestionPolicy) -> crate::Result
|
|||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove_file_or_dir(path)?;
|
||||||
|
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn remove_file_or_dir(path: &Path) -> crate::Result<()> {
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
fs::remove_dir_all(path)?;
|
fs::remove_dir_all(path)?;
|
||||||
} else if path.is_file() {
|
} else if path.is_file() {
|
||||||
fs::remove_file(path)?;
|
fs::remove_file(path)?;
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
Ok(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a directory at the path, if there is nothing there.
|
/// Creates a directory at the path, if there is nothing there.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user