You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
389 B

use std::fs;
use std::io;
use std::path::Path;
/// Ensure a directory exists, creating it with parents if necessary.
pub fn ensure_dir_exists(path: &Path) -> Result<(), io::Error> {
if !path.is_dir() {
if path.exists() {
return Err(io::Error::new(io::ErrorKind::AlreadyExists, "Not a directory."));
}
fs::create_dir_all(&path)?;
}
Ok(())
}