treewalk

Crates.iotreewalk
lib.rstreewalk
version0.1.4
sourcesrc
created_at2023-01-02 20:11:01.235674
updated_at2023-01-15 21:05:56.528657
descriptionCommon utilities for exploring a file tree
homepage
repositoryhttps://github.com/paytonward6/treewalk
max_upload_size
id749642
size17,594
Payton (paytonward6)

documentation

README

Crate Info

treewalk

Common utilities for exploring a file tree

Example usage

    use std::path::{Path, PathBuf};
    use treewalk::walk::{comparison, lineage, format, utils};

    fn main() {
        let path = Path::new("./foo/bar");
        let children: Vec<PathBuf> = lineage::get_all_children(&path.to_path_buf()).unwrap();

        // or create children from strings via
        let children_from_strs = utils::tree!["./this_file.txt", "./that_file.txt"];

        // get the largest file
        let largest = comparison::largest_file(&children);
        if let Some(file_name) = &largest.name {
            println!("{:?}: {:?}", file_name, format::human_readable(largest.size, false));
        }

        // get only dotfiles
        let dotfiles: Vec<PathBuf> = children
            .into_iter()
            .filter(|path| comparison::is_dotfile(path))
            .collect();
        println!("{:?}", dotfiles);

    }

Commit count: 39

cargo fmt