summaryrefslogtreecommitdiff
path: root/src/operations/mkdir.rs
blob: 011b8cfc9fec206c353a0eeb49af4b9da48bfe2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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(()),
    }
}