#fs #filesystem #files #traversal

fwalker

Library for file and directory traversal in a file system

8 unstable releases (3 breaking)

new 0.4.0 Jan 17, 2021
0.3.4 Jan 12, 2021
0.3.2 Nov 23, 2020
0.3.0 May 26, 2020
0.1.0 Apr 1, 2020

#107 in Filesystem

Download history 8/week @ 2020-10-01 1/week @ 2020-10-08 4/week @ 2020-10-15 4/week @ 2020-10-22 37/week @ 2020-11-05 25/week @ 2020-11-12 85/week @ 2020-11-19 10/week @ 2020-11-26 5/week @ 2020-12-03 3/week @ 2020-12-10 5/week @ 2020-12-31 34/week @ 2021-01-07 46/week @ 2021-01-14

73 downloads per month

MIT license

22KB
479 lines

fwalker🚶

A cargo crate for file and directory traversal in a file system through an iterator

Build & Test Security Audit License: MIT

Documentation

See docs.rs/fwalker for complete documentation and more advanced usage.

Usage

Add crate to Cargo.toml to use it

[dependencies]
fwalker = "0.3"

This crate has only one public struct, fwalker::Walker. With this struct, files and directories can be iterated over for any kind of listing, manipulation or processing. Creating a new walker can be done with either

  • fwalker::Walker::new() - starts from current directory
  • fwalker::Walker::from("/some/path") - starts from path /some/path

Quick example to get you started

use fwalker::Walker;
use std::path::PathBuf;

fn main() {
    Walker::from("/proc/sys")
        .expect("This *should* work")
        .take(10)
        .for_each(|file: PathBuf| println!("{:?}", file));
}

which would yield the output

"/proc/sys/abi/vsyscall32"
"/proc/sys/debug/exception-trace"
"/proc/sys/debug/kprobes-optimization"
"/proc/sys/fs/aio-max-nr"
"/proc/sys/fs/aio-nr"
"/proc/sys/fs/dentry-state"
"/proc/sys/fs/dir-notify-enable"
"/proc/sys/fs/file-max"
"/proc/sys/fs/file-nr"
"/proc/sys/fs/inode-nr"

Dependencies

~465–770KB
~17K SLoC