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)?;
}
Recursively create a directory and all of its parent components if they are missing.
Examples
use std::fs; fs::create_dir_all("/some/dir")?;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.