mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2024-12-12 19:18:24 +02:00
d79add341b
This PR introduces a new sub-crate, `ignore`, which primarily provides a fast recursive directory iterator that respects ignore files like gitignore and other configurable filtering rules based on globs or even file types. This results in a substantial source of complexity moved out of ripgrep's core and into a reusable component that others can now (hopefully) benefit from. While much of the ignore code carried over from ripgrep's core, a substantial portion of it was rewritten with the following goals in mind: 1. Reuse matchers built from gitignore files across directory iteration. 2. Design the matcher data structure to be amenable for parallelizing directory iteration. (Indeed, writing the parallel iterator is the next step.) Fixes #9, #44, #45
29 lines
657 B
Rust
29 lines
657 B
Rust
/*
|
|
extern crate ignore;
|
|
extern crate walkdir;
|
|
|
|
use std::env;
|
|
use std::io::{self, Write};
|
|
use std::os::unix::ffi::OsStrExt;
|
|
|
|
use ignore::ignore::IgnoreBuilder;
|
|
use walkdir::WalkDir;
|
|
|
|
fn main() {
|
|
let path = env::args().nth(1).unwrap();
|
|
let ig = IgnoreBuilder::new().build();
|
|
let wd = WalkDir::new(path);
|
|
let walker = ignore::walk::Iter::new(ig, wd);
|
|
|
|
let mut stdout = io::BufWriter::new(io::stdout());
|
|
// let mut count = 0;
|
|
for dirent in walker {
|
|
// count += 1;
|
|
stdout.write(dirent.path().as_os_str().as_bytes()).unwrap();
|
|
stdout.write(b"\n").unwrap();
|
|
}
|
|
// println!("{}", count);
|
|
}
|
|
*/
|
|
fn main() {}
|