#regex #glob #pattern #walk #iterator

globwalk

Glob-matched recursive file system walking

9 releases (breaking)

0.7.1 May 10, 2019
0.7.0 Feb 23, 2019
0.6.0 Jan 21, 2019
0.5.0 Sep 8, 2018
0.1.0 Feb 20, 2018

#21 in Filesystem

Download history 2254/week @ 2019-07-30 2825/week @ 2019-08-06 1704/week @ 2019-08-13 1539/week @ 2019-08-20 1474/week @ 2019-08-27 1407/week @ 2019-09-03 869/week @ 2019-09-10 1601/week @ 2019-09-17 1320/week @ 2019-09-24 1410/week @ 2019-10-01 1630/week @ 2019-10-08 1873/week @ 2019-10-15 2584/week @ 2019-10-22 2356/week @ 2019-10-29 1991/week @ 2019-11-05

4,402 downloads per month
Used in 43 crates (11 directly)

MIT license

34KB
628 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.7"

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
~72K SLoC