use ignore::Walk;
use std::fs::File;
use std::io::prelude::Read;
pub fn walk<T: FnMut(&str, &str) -> ()>(path: &str, mut callback: T) -> usize {
let mut files_scanned: usize = 0;
for result in Walk::new(path) {
if let Ok(dir_entry) = result {
if dir_entry.file_type().unwrap().is_file() {
let mut possible_file = File::open(dir_entry.path());
if let Ok(mut file) = possible_file {
let mut contents = String::new();
if let Ok(_) = file.read_to_string(&mut contents) {
files_scanned += 1;
callback(
&dir_entry.path().to_string_lossy().into_owned(),
&contents
);
}
}
}
}
}
files_scanned
}