#directory-traversal #recursion #directory #file #search

dir_rec

0 dependencies recursive directory traversal tool

3 releases

0.1.2 Jan 19, 2025
0.1.1 Jan 19, 2025
0.1.0 Jan 19, 2025

#855 in Filesystem

Download history 155/week @ 2025-01-13 141/week @ 2025-01-20

296 downloads per month

MIT license

5KB

dir_rec.rs

You just copy dir_rec.rs file to your project and use it.

example.rs

use std::env;
use std::process::ExitCode;

use dir_rec::DirRec; 

fn main() -> ExitCode {
    let args = env::args().collect::<Vec::<_>>();
    if args.len() < 2 {
        eprintln!("usage: {program} <directory to traverse recursively>", program = args[0]);
        return ExitCode::FAILURE
    }

    let ref dir_path = args[1];
    let dir = DirRec::new(dir_path);

    for file_path in dir.into_iter() {
        println!("{entry}", entry = file_path.display());
    }

    ExitCode::SUCCESS
}

No runtime deps