#regex #glob #pattern #walk #iterator

globwalk

Glob-matched recursive file system walking

7 releases (breaking)

0.6.0 Jan 21, 2019
0.5.0 Sep 8, 2018
0.4.0 Aug 31, 2018
0.3.1 Apr 20, 2018
0.1.0 Feb 20, 2018

#31 in Filesystem

Download history 29/week @ 2018-10-09 124/week @ 2018-10-16 64/week @ 2018-10-23 288/week @ 2018-10-30 143/week @ 2018-11-06 104/week @ 2018-11-13 38/week @ 2018-11-20 249/week @ 2018-11-27 315/week @ 2018-12-04 221/week @ 2018-12-11 257/week @ 2018-12-18 1343/week @ 2018-12-25 653/week @ 2019-01-01 305/week @ 2019-01-08 352/week @ 2019-01-15

928 downloads per month
Used in 12 crates (6 directly)

MIT license

29KB
517 lines

GlobWalk

Build Status Build status License crates.io

Recursively find files in a directory using globs.

Based on both walkdir & ignore (❤), this crate inherits many goodies from both, such as limiting search depth and amount of open file descriptors.

Licensed under MIT.

Why not glob

  • The glob crate does not support having {a,b} in patterns.
  • globwalk can match several glob-patterns at the same time.
  • globwalk supports excluding results with !.
  • glob searches for files in the current working directory, whereas globwalk starts at a specified base-dir.

Usage

To use this crate, add globwalk as a dependency to your project's Cargo.toml:

[dependencies]
globwalk = "0.6"

The following piece of code recursively find all mp3 and FLAC files:

extern crate globwalk;

use std::fs;

for img in globwalk::glob("*.{png,jpg,gif}").unwrap() {
    if let Ok(img) = img {
        fs::remove_file(img.path()).unwrap();
    }
}

See the documentation for more details.

Dependencies

~3MB
~49K SLoC