#glob #ignore #gitignore #pattern #file

ignore

A fast library for efficiently matching ignore files such as .gitignore against file paths

26 releases

0.4.10 Aug 6, 2019
0.4.8 Jul 24, 2019
0.4.6 Dec 30, 2018
0.4.4 Sep 7, 2018
0.1.5 Nov 10, 2016

#8 in Filesystem

Download history 14560/week @ 2019-07-26 14299/week @ 2019-08-02 13573/week @ 2019-08-09 11641/week @ 2019-08-16 11432/week @ 2019-08-23 12352/week @ 2019-08-30 11931/week @ 2019-09-06 11900/week @ 2019-09-13 12445/week @ 2019-09-20 13157/week @ 2019-09-27 16569/week @ 2019-10-04 14328/week @ 2019-10-11 15749/week @ 2019-10-18 19091/week @ 2019-10-25 18720/week @ 2019-11-01

61,711 downloads per month
Used in 158 crates (59 directly)

Unlicense/MIT

285KB
6K SLoC

ignore

The ignore crate provides a fast recursive directory iterator that respects various filters such as globs, file types and .gitignore files. This crate also provides lower level direct access to gitignore and file type matchers.

Linux build status Windows build status

Dual-licensed under MIT or the UNLICENSE.

Documentation

https://docs.rs/ignore

Usage

Add this to your Cargo.toml:

[dependencies]
ignore = "0.4"

and this to your crate root:

extern crate ignore;

Example

This example shows the most basic usage of this crate. This code will recursively traverse the current directory while automatically filtering out files and directories according to ignore globs found in files like .ignore and .gitignore:

use ignore::Walk;

for result in Walk::new("./") {
    // Each item yielded by the iterator is either a directory entry or an
    // error, so either print the path or the error.
    match result {
        Ok(entry) => println!("{}", entry.path().display()),
        Err(err) => println!("ERROR: {}", err),
    }
}

Example: advanced

By default, the recursive directory iterator will ignore hidden files and directories. This can be disabled by building the iterator with WalkBuilder:

use ignore::WalkBuilder;

for result in WalkBuilder::new("./").hidden(false).build() {
    println!("{:?}", result);
}

See the documentation for WalkBuilder for many other options.

Dependencies

~3MB
~67K SLoC