pub fn delete_folder(dpath: &Path) -> Result<(), RdError>Expand description
Deletes a directory and all its contents in parallel.
This function performs a fast, parallel deletion of a directory by:
- Walking the directory tree to catalog all subdirectories by depth
- Deleting directories in parallel, starting from the deepest level
- If deletion fails, attempting to fix permission issues and retrying
The parallel approach significantly speeds up deletion of large directory trees.
§Arguments
dpath- The path to the directory to delete
§Errors
Returns an error if:
- The directory walk fails
- Permissions cannot be fixed
- The final deletion attempt fails
§Examples
use std::path::PathBuf;
let path = PathBuf::from("/tmp/test_dir");
delete_folder(&path)?;