create_folder_for_file

Function create_folder_for_file 

Source
pub fn create_folder_for_file<P: AsRef<Path>>(path: P)
Expand description

Creates the parent folder for a file at the specified path if it does not already exist.

§Arguments

§Panics

If some error is encountered while creating the parent folder.

§Examples

§Using a string literal

use file_io::create_folder_for_file;
     
let path: &str = "folder/subfolder_3/file_1.txt";

// This will create "folder/subfolder_3" if it does not exist.
create_folder_for_file(path);

§Using a Path reference

use file_io::create_folder_for_file;
use std::path::Path;

let path: &Path = Path::new("folder/subfolder_4/file_2.txt");

// This will create "folder/subfolder_4" if it does not exist.
create_folder_for_file(path);