diff options
author | Ben Bridle <bridle.benjamin@gmail.com> | 2023-12-19 16:23:29 +1300 |
---|---|---|
committer | Ben Bridle <bridle.benjamin@gmail.com> | 2023-12-19 16:23:29 +1300 |
commit | 47b25c05a6be51b93c909d38a19440d1c04ba2f8 (patch) | |
tree | 448c23c6d58a8407de45a4730cf972bd83713aa0 /src/operations/mkdir.rs | |
parent | 8f410d1ead74b979481f1488a4dcddd33ea829c7 (diff) | |
download | vagabond-1.0.0.zip |
Large collection of changesv1.0.0
Diffstat (limited to 'src/operations/mkdir.rs')
-rw-r--r-- | src/operations/mkdir.rs | 21 |
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(()), |