#regex #glob #pattern #walk #iterator

globwalk

Glob-matched recursive file system walking

6 releases (breaking)

0.5.0 Sep 8, 2018
0.4.0 Aug 31, 2018
0.3.1 Apr 20, 2018
0.2.0 Apr 4, 2018
0.1.0 Feb 20, 2018

#38 in Filesystem

Download history 52/week @ 2018-08-08 61/week @ 2018-08-15 27/week @ 2018-08-22 14/week @ 2018-08-29 175/week @ 2018-09-05 55/week @ 2018-09-12 23/week @ 2018-09-19 24/week @ 2018-09-26 189/week @ 2018-10-03 62/week @ 2018-10-10 95/week @ 2018-10-17 66/week @ 2018-10-24 55/week @ 2018-10-31

348 downloads per month
Used in 9 crates (4 directly)

MIT license

27KB
467 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.3"

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

~4MB
~67K SLoC