| Crates.io | finder |
| lib.rs | finder |
| version | 0.1.6 |
| created_at | 2019-08-22 10:13:38.656711+00 |
| updated_at | 2020-09-05 13:17:56.897733+00 |
| description | Recursive find files in folders with filtering |
| homepage | https://github.com/ChugunovRoman/finder |
| repository | https://github.com/ChugunovRoman/finder |
| max_upload_size | |
| id | 158843 |
| size | 19,958 |
Crate finder is a very simple and lightweight file searcher with the filtering of files.
It provides an efficient implementation of recursive file search.
To use this crate, add finder as a dependency to your project's
Cargo.toml:
[dependencies]
finder = "0.1"
The following code recursively search all files in /foo and /bar diresctories:
extern crate finder;
use finder::Finder;
fn main() {
let finders = Finder::new("/foo:/bar");
for i in finders.into_iter() {
println!("{}", i.path().to_str().unwrap());
}
}
The following code recursively search .ttf and .ttc files in /foo and /bar diresctories:
extern crate finder;
use std::fs::DirEntry;
use finder::Finder;
fn is_font_file(e: &DirEntry) -> bool {
if let Some(s) = e.path().file_name() {
let name = String::from(s.to_str().unwrap());
if (name.ends_with(".ttf") || name.ends_with(".ttc")) {
return true;
}
}
false
}
fn main() {
let finders = Finder::new("/foo:/bar");
for i in finders.filter(&is_font_file).into_iter() {
println!("{}", i.path().to_str().unwrap());
}
}