#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

#25 in Filesystem

Download history 644/week @ 2019-03-24 934/week @ 2019-03-31 1179/week @ 2019-04-07 974/week @ 2019-04-14 1456/week @ 2019-04-21 1080/week @ 2019-04-28 1227/week @ 2019-05-05 917/week @ 2019-05-12 1007/week @ 2019-05-19 1787/week @ 2019-05-26 1608/week @ 2019-06-02 1174/week @ 2019-06-09 2594/week @ 2019-06-16 3432/week @ 2019-06-23 2173/week @ 2019-06-30

4,402 downloads per month
Used in 33 crates (9 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

~3.5MB
~73K SLoC