From 47b25c05a6be51b93c909d38a19440d1c04ba2f8 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Tue, 19 Dec 2023 16:23:29 +1300 Subject: Large collection of changes --- src/operations/mkdir.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/operations/mkdir.rs') 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

(path: P) -> Result<(), EntryWriteError> -where - P: AsRef, -{ - 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) -> 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

(path: P) -> Result<(), EntryWriteError> -where - P: AsRef, -{ +/// Create the parent directory of a path. +#[must_use] +pub fn make_parent_directory(path: impl AsRef) -> WriteResult<()> { match path.as_ref().parent() { Some(parent) => make_directory(parent), None => Ok(()), -- cgit v1.2.3-70-g09d2