summaryrefslogtreecommitdiff
path: root/src/operations/rm.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/operations/rm.rs')
-rw-r--r--src/operations/rm.rs30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/operations/rm.rs b/src/operations/rm.rs
index 846a094..bf206a5 100644
--- a/src/operations/rm.rs
+++ b/src/operations/rm.rs
@@ -1,23 +1,17 @@
-use crate::EntryWriteError;
-use crate::{get_entry, EntryType};
-use std::path::Path;
+use crate::*;
-pub fn remove<P>(path: P) -> Result<(), EntryWriteError>
-where
- P: AsRef<Path>,
-{
+#[must_use]
+pub fn remove(path: impl AsRef<Path>) -> WriteResult<()> {
let entry = get_entry(&path)?;
- match entry.entry_type {
- EntryType::File => std::fs::remove_file(&path)?,
- EntryType::Directory => std::fs::remove_dir_all(&path)?,
- }
- Ok(())
+ let remove_result = match entry.entry_type {
+ EntryType::File => std::fs::remove_file(&path),
+ EntryType::Directory => std::fs::remove_dir_all(&path),
+ };
+ Ok(io_result_to_write_result(remove_result, path.as_ref())?)
}
-pub fn remove_file<P>(path: P) -> Result<(), EntryWriteError>
-where
- P: AsRef<Path>,
-{
- std::fs::remove_file(path)?;
- Ok(())
+#[must_use]
+pub fn remove_file(path: impl AsRef<Path>) -> WriteResult<()> {
+ let remove_result = std::fs::remove_file(&path);
+ Ok(io_result_to_write_result(remove_result, &path.as_ref())?)
}