#recursive #iterator #fonts

bin+lib finder

Recursive find files in folders with filtering

7 releases

0.1.6 Sep 5, 2020
0.1.5 Sep 5, 2019
0.1.1 Aug 22, 2019

#259 in Filesystem

Download history 24/week @ 2022-04-22 49/week @ 2022-04-29 56/week @ 2022-05-06 145/week @ 2022-05-13 45/week @ 2022-05-20 71/week @ 2022-05-27 70/week @ 2022-06-03 14/week @ 2022-06-10 17/week @ 2022-06-17 13/week @ 2022-06-24 30/week @ 2022-07-01 17/week @ 2022-07-08 28/week @ 2022-07-15 31/week @ 2022-07-22 19/week @ 2022-07-29 18/week @ 2022-08-05

97 downloads per month
Used in libfonthelper

MIT license

10KB
203 lines

Finder

Codacy Badge Buy Me A Coffee donate button PayPal donate button

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"

Example

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());
  }
}

Example with filter

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());
  }
}

Dependencies

~84KB