Recursive walker that stops descending into ignored directories.
(
root: &Path,
dir: &Path,
rules: &crate::ignore::IgnoreRules,
out: &mut Vec<String>,
)
| 377 | |
| 378 | // Recursive walker that stops descending into ignored directories. |
| 379 | fn walk( |
| 380 | root: &Path, |
| 381 | dir: &Path, |
| 382 | rules: &crate::ignore::IgnoreRules, |
| 383 | out: &mut Vec<String>, |
| 384 | ) { |
| 385 | let entries = match std::fs::read_dir(dir) { |
| 386 | Ok(e) => e, |
| 387 | Err(_) => return, |
| 388 | }; |
| 389 | for entry in entries.flatten() { |
| 390 | let abs = entry.path(); |
| 391 | let rel = match abs.strip_prefix(root) { |
| 392 | Ok(r) => r, |
| 393 | Err(_) => continue, |
| 394 | }; |
| 395 | |
| 396 | // Never touch the .atomic directory itself. |
| 397 | if rel.starts_with(DOT_DIR) { |
| 398 | continue; |
| 399 | } |
| 400 | |
| 401 | let is_dir = abs.is_dir(); |
| 402 | |
| 403 | if rules.is_ignored(rel, is_dir) { |
| 404 | // Collect the top-level ignored entry — don't recurse. |
| 405 | if let Some(s) = rel.to_str() { |
| 406 | out.push(s.to_string()); |
| 407 | } |
| 408 | } else if is_dir { |
| 409 | // Not ignored — recurse to find ignored children. |
| 410 | walk(root, &abs, rules, out); |
| 411 | } |
| 412 | // Non-ignored files are left alone. |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | walk(&self.root, &self.root, &rules, &mut result); |
| 417 | result |
no test coverage detected