21 lines
434 B
Rust
21 lines
434 B
Rust
use crate::EntryWriteError;
|
|
use std::path::Path;
|
|
|
|
pub fn make_directory<P>(path: P) -> Result<(), EntryWriteError>
|
|
where
|
|
P: AsRef<Path>,
|
|
{
|
|
std::fs::DirBuilder::new().recursive(true).create(path)?;
|
|
Ok(())
|
|
}
|
|
|
|
pub fn make_parent_directory<P>(path: P) -> Result<(), EntryWriteError>
|
|
where
|
|
P: AsRef<Path>,
|
|
{
|
|
match path.as_ref().parent() {
|
|
Some(parent) => make_directory(parent),
|
|
None => Ok(()),
|
|
}
|
|
}
|