Walk a directory tree recursively in Rust, efficiently and on every platform
open sourceUnlicense OR MITfree
walkdir is a cross-platform Rust library by Andrew Gallant for walking a directory recursively. It can follow symbolic links, limits how many file descriptors it keeps open, and prunes the tree efficiently with filter_entry, so a walk can skip hidden directories or whole subtrees without descending into them. Its author reports performance comparable to find and glibc's nftw on warm and cold caches, with as few system calls and allocations as it can manage. It is dual-licensed under MIT or the Unlicense.
Problems it solves
- list every file under a directory in my Rust program
- walk a directory tree in Rust while skipping hidden folders
- recursively scan a large folder in Rust without running out of file descriptors
Features
- Recursive directory iteration on Linux, macOS and Windows
- Optionally follows symbolic links
- Caps the number of open file descriptors
- filter_entry prunes subtrees without descending into them
- Performance comparable to find and nftw
Alternatives
The same job
These do what walkdir does.
- glob Match file paths against Unix shell style patterns in Rust
- tempfile Secure, cross-platform temporary files and directories for Rust
- Notify (Rust) Cross-platform filesystem notification library for Rust
