From 8f410d1ead74b979481f1488a4dcddd33ea829c7 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Thu, 25 Aug 2022 21:27:39 +1200 Subject: Initial commit --- src/operations/mkdir.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/operations/mkdir.rs (limited to 'src/operations/mkdir.rs') diff --git a/src/operations/mkdir.rs b/src/operations/mkdir.rs new file mode 100644 index 0000000..011b8cf --- /dev/null +++ b/src/operations/mkdir.rs @@ -0,0 +1,20 @@ +use crate::EntryWriteError; +use std::path::Path; + +pub fn make_directory

(path: P) -> Result<(), EntryWriteError> +where + P: AsRef, +{ + std::fs::DirBuilder::new().recursive(true).create(path)?; + Ok(()) +} + +pub fn make_parent_directory

(path: P) -> Result<(), EntryWriteError> +where + P: AsRef, +{ + match path.as_ref().parent() { + Some(parent) => make_directory(parent), + None => Ok(()), + } +} -- cgit v1.2.3-70-g09d2