pub fn ensure_directory(path: &Path, dir_type: &str) -> Result<(), ProcessError>Expand description
Ensures the specified directory exists, creating it if necessary.
§Arguments
path- The path of the directory to check.dir_type- A label describing the directory type (e.g., “content”, “output”).
§Returns
Result<(), ProcessError>- ReturnsOkif the directory exists or is successfully created.
§Errors
- Returns
ProcessError::DirectoryCreationif the directory cannot be created due to permissions or other issues.
§Examples
use ssg::process::ensure_directory;
use tempfile::tempdir;
let dir = tempdir().unwrap();
let new = dir.path().join("created");
ensure_directory(&new, "output").unwrap();
assert!(new.is_dir());