[][src]Function fsio::directory::create_parent

pub fn create_parent<T: AsPath + ?Sized>(path: &T) -> Result<(), FsIOError>

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

extern crate fsio;

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());
}