Files
sausage/userland/fd/src/wasi_walk.rs
T
surma b9e3e3677d userland: search and exec tools, spawn library (T14)
rg (ripgrep 15.2), grep (ours, on ripgrep's regex crates), find and xargs
(ours), sed (uutils 0.3 wrapper), diff and cmp (uutils diffutils 0.6 with -r),
fd 10.5, jaq 2.3, env and timeout. userland/spawn is a small Command-like
client of the process interface. search-test.nu: 42 cases match native tools.
2026-11-06 17:21:51 +00:00

22 lines
834 B
Rust

//! Run fd's visitor on the single-threaded ignore walker.
use ignore::{DirEntry, Error, Walk, WalkState};
pub struct WalkParallel(pub Walk);
impl WalkParallel {
pub fn run<'a>(self, factory: impl FnOnce() -> Box<dyn FnMut(Result<DirEntry, Error>) -> WalkState + 'a>) {
let mut visit = factory();
let mut skip: Option<std::path::PathBuf> = None;
for entry in self.0 {
if let Ok(e) = &entry {
if skip.as_ref().is_some_and(|p| e.path().starts_with(p)) { continue; }
skip = None;
}
let path = entry.as_ref().ok().map(|e| e.path().to_owned());
match visit(entry) {
WalkState::Quit => break,
WalkState::Skip => skip = path,
WalkState::Continue => (),
}
}
}
}