Skip to main content

ensure_directory

Function ensure_directory 

Source
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> - Returns Ok if the directory exists or is successfully created.

§Errors

  • Returns ProcessError::DirectoryCreation if the directory cannot be created due to permissions or other issues.

§Example

let path = Path::new("path/to/output");
ensure_directory(path, "output").expect("Failed to ensure directory exists");