From 4d2ccf48732ecff63547ab77a542ae58613c10eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20M=2E=20Bezerra?= Date: Sat, 15 Oct 2022 21:51:52 -0300 Subject: [PATCH] create remove_file_or_dir util --- src/utils/fs.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils/fs.rs b/src/utils/fs.rs index 241ec97..6f6f1f1 100644 --- a/src/utils/fs.rs +++ b/src/utils/fs.rs @@ -29,13 +29,18 @@ pub fn clear_path(path: &Path, question_policy: QuestionPolicy) -> crate::Result return Ok(false); } + remove_file_or_dir(path)?; + + Ok(true) +} + +pub fn remove_file_or_dir(path: &Path) -> crate::Result<()> { if path.is_dir() { fs::remove_dir_all(path)?; } else if path.is_file() { fs::remove_file(path)?; } - - Ok(true) + Ok(()) } /// Creates a directory at the path, if there is nothing there.