Skip to main content

walk_files

Function walk_files 

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

Recursively collects files matching extension under dir.

Sorted output, no recursion (uses an explicit stack), no depth or count bounds. Returns Ok(Vec::new()) if dir does not exist.

ยงExamples

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

let dir = tempdir().unwrap();
fs::write(dir.path().join("a.md"), "").unwrap();
fs::write(dir.path().join("b.txt"), "").unwrap();
let mds = walk_files(dir.path(), "md").unwrap();
assert_eq!(mds.len(), 1);