pub fn final_folders_from_subdir(
current_path: &Path,
ignore_empty_folders: bool,
) -> Result<Vec<PathBuf>>Expand description
Returns all leaf directories (folders with no subfolders) in a directory tree.
This function recursively scans a directory and returns all directories that don’t contain any subdirectories (leaf nodes in the directory tree).
§Arguments
current_path- The directory to start scanning fromignore_empty_folders- Iftrue, only includes folders that contain files; iffalse, includes all leaf folders
§Returns
Returns a vector of paths to all leaf directories, or an error if any directory cannot be read.
§Examples
// Get all leaf folders, including empty ones
let leaves = final_folders_from_subdir(Path::new("./project"), false)?;
// Get only leaf folders that contain files
let non_empty_leaves = final_folders_from_subdir(Path::new("./project"), true)?;