Skip to main content

walk_files_bounded_depth

Function walk_files_bounded_depth 

Source
pub fn walk_files_bounded_depth(
    dir: &Path,
    extension: &str,
    max_depth: usize,
) -> Result<Vec<PathBuf>, SsgError>
Expand description

Recursively collects files matching extension, bounded by depth.

Subdirectories beyond max_depth are silently skipped. Used by content walkers that respect crate::MAX_DIR_DEPTH as a guard against pathological symlink loops.

ยงExamples

use ssg::walk::walk_files_bounded_depth;
use tempfile::tempdir;
use std::fs;

let dir = tempdir().unwrap();
fs::write(dir.path().join("a.md"), "").unwrap();
let v = walk_files_bounded_depth(dir.path(), "md", 4).unwrap();
assert_eq!(v.len(), 1);