Reputation:
I tried the following but I don't think it's particularly pretty:
let path = "target/dir";
if !std::path::Path::new(&path).exists() {
std::fs::create_dir(path)?;
}
Upvotes: 77
Views: 38294
Reputation: 431479
Recursively create a directory and all of its parent components if they are missing.
Examples
use std::fs; fs::create_dir_all("/some/dir")?;
Upvotes: 109