#directory #recursive #walk #iterator #parallel

jwalk

Filesystem walk performed in parallel with streamed and sorted results

9 releases (5 breaking)

0.6.0 Jan 6, 2021
0.5.2 Dec 28, 2020
0.5.1 Mar 13, 2020
0.4.0 May 24, 2019
0.1.1 Feb 9, 2019

#31 in Filesystem

Download history 580/week @ 2021-04-05 491/week @ 2021-04-12 499/week @ 2021-04-19 687/week @ 2021-04-26 788/week @ 2021-05-03 591/week @ 2021-05-10 486/week @ 2021-05-17 606/week @ 2021-05-24 537/week @ 2021-05-31 736/week @ 2021-06-07 515/week @ 2021-06-14 466/week @ 2021-06-21 666/week @ 2021-06-28 571/week @ 2021-07-05 776/week @ 2021-07-12 637/week @ 2021-07-19

2,735 downloads per month
Used in 17 crates (12 directly)

MIT license

68KB
1.5K SLoC

jwalk

Filesystem walk.

  • Performed in parallel using rayon
  • Entries streamed in sorted order
  • Custom sort/filter/skip/state

Build Status Latest version

Usage

Add this to your Cargo.toml:

[dependencies]
jwalk = "0.5"

Lean More: docs.rs/jwalk

Example

Recursively iterate over the "foo" directory sorting by name:

use jwalk::{WalkDir};

for entry in WalkDir::new("foo").sort(true) {
  println!("{}", entry?.path().display());
}

Inspiration

This crate is inspired by both walkdir and ignore. It attempts to combine the parallelism of ignore with walkdir's streaming iterator API. Some code and comments are copied directly from walkdir.

Why use this crate?

This crate is particularly fast when you want streamed sorted results. In my tests its about 4x walkdir speed for sorted results with metadata. Also this crate's process_read_dir callback allows you to arbitrarily sort/filter/skip/state entries before they are yielded.

Why not use this crate?

Directory traversal is already pretty fast. If you don't need this crate's speed then walkdir provides a smaller and more tested single threaded implementation.

This crates parallelism happens at the directory level. It will help when walking deep file systems with many directories. It wont help when reading a single directory with many files.

Benchmarks

Benchmarks comparing this crate with walkdir and ignore.

Dependencies

~1.5MB
~27K SLoC