summaryrefslogtreecommitdiff
path: root/src/operations/mkdir.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/operations/mkdir.rs')
-rw-r--r--src/operations/mkdir.rs21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/operations/mkdir.rs b/src/operations/mkdir.rs
index 011b8cf..9b2abd2 100644
--- a/src/operations/mkdir.rs
+++ b/src/operations/mkdir.rs
@@ -1,18 +1,15 @@
-use crate::EntryWriteError;
-use std::path::Path;
+use crate::*;
-pub fn make_directory<P>(path: P) -> Result<(), EntryWriteError>
-where
- P: AsRef<Path>,
-{
- std::fs::DirBuilder::new().recursive(true).create(path)?;
- Ok(())
+/// Create a new directory and all parent directories.
+#[must_use]
+pub fn make_directory(path: impl AsRef<Path>) -> WriteResult<()> {
+ let make_result = std::fs::DirBuilder::new().recursive(true).create(&path);
+ Ok(io_result_to_write_result(make_result, &path.as_ref())?)
}
-pub fn make_parent_directory<P>(path: P) -> Result<(), EntryWriteError>
-where
- P: AsRef<Path>,
-{
+/// Create the parent directory of a path.
+#[must_use]
+pub fn make_parent_directory(path: impl AsRef<Path>) -> WriteResult<()> {
match path.as_ref().parent() {
Some(parent) => make_directory(parent),
None => Ok(()),