#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

#42 in Filesystem

Download history 123/week @ 2018-06-16 25/week @ 2018-06-23 111/week @ 2018-06-30 56/week @ 2018-07-07 7/week @ 2018-07-14 29/week @ 2018-07-21 16/week @ 2018-07-28 362/week @ 2018-08-04 42/week @ 2018-08-11 59/week @ 2018-08-18 21/week @ 2018-08-25 140/week @ 2018-09-01 54/week @ 2018-09-08

348 downloads per month
Used in 3 crates

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