#directory #parallel #recursion #walk #iterator #walk-dir

jwalk

Filesystem walk performed in parallel with streamed and sorted results

13 releases (7 breaking)

0.8.1 Dec 15, 2022
0.7.0 Dec 15, 2022
0.6.0 Jan 6, 2021
0.5.2 Dec 28, 2020
0.3.0 Feb 21, 2019

#55 in Filesystem

Download history 56024/week @ 2024-08-02 64192/week @ 2024-08-09 56889/week @ 2024-08-16 50983/week @ 2024-08-23 49742/week @ 2024-08-30 55284/week @ 2024-09-06 49275/week @ 2024-09-13 46314/week @ 2024-09-20 51158/week @ 2024-09-27 51596/week @ 2024-10-04 50743/week @ 2024-10-11 49219/week @ 2024-10-18 41290/week @ 2024-10-25 33521/week @ 2024-11-01 31226/week @ 2024-11-08 33608/week @ 2024-11-15

147,533 downloads per month
Used in 434 crates (83 directly)

MIT license

66KB
1K SLoC

jwalk

Filesystem walk.

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

Build Status

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 good when you want streamed sorted results. In my tests it's 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
~25K SLoC