Skip to main content

Module walk

Module walk 

Source
Expand description

Shared bounded directory walkers.

Replaces the per-plugin collect_*_files helpers that previously lived in nearly every module. Each function performs an iterative (no-recursion) walk with optional bounds and returns a sorted Vec<PathBuf> for deterministic test output.

§Variants

All variants return Ok(Vec::new()) when the root directory does not exist or is not a directory — matching the convention used by every previous local collector in the crate.

The collecting walkers follow symlinked directories, but enter each real directory (by canonical path) at most once. A link back to an ancestor is therefore skipped instead of walked again, so a symlink loop can neither repeat files nor make the walk branch without end. Subdirectories are visited in sorted order, so when one directory is reachable by two names the name kept is the same on every platform.

Functions§

visit_files_bounded_depth
Visits every file with extension ext under dir, in a deterministic order, without materialising the file list.
walk_files
Recursively collects files matching extension under dir.
walk_files_bounded_count
Recursively collects files matching extension, capped at max_files. Provides with_context on the underlying read_dir failure.
walk_files_bounded_depth
Recursively collects files matching extension, bounded by depth.
walk_files_multi
Recursively collects files matching any of extensions under dir.