1 个不稳定版本
0.1.4 | 2023年1月15日 |
---|---|
0.1.3 |
|
0.1.2 |
|
0.1.1 |
|
0.1.0 |
|
#1410 in 文件系统
12KB
205 代码行
treewalk
文件树探索的常用工具
使用示例
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);
}