Skip to main content

create_parent

Function create_parent 

Source
pub fn create_parent<T: AsPath + ?Sized>(path: &T) -> FsIOResult<()>
Expand description

Creates the parent directory (and if needed the parent directories) for the provided path. In case no parent directory path component exists, this function will return ok result.

§Arguments

  • path - The child path

§Example

use crate::fsio::directory;
use std::path::Path;

fn main() {
    let result = directory::create_parent("./target/__test/directory_test/dir1/files/file.txt");
    assert!(result.is_ok());

    let path = Path::new("./target/__test/directory_test/dir1/files");
    assert!(path.exists());
}