1
0
mirror of https://github.com/jht5945/finding.git synced 2025-12-27 13:20:03 +08:00

add huge file scan

This commit is contained in:
2019-07-22 00:22:56 +08:00
parent de0013772c
commit dfb83af83e

View File

@@ -21,7 +21,7 @@ fn main() {
let mut version = false;
let mut target = String::from("text");
let mut huge_file_size = String::from("100M");
let mut dir = String::new();
let mut dir = String::from(".");
{
let mut ap = ArgumentParser::new();
ap.set_description("finding - command line find tool.");
@@ -37,6 +37,39 @@ fn main() {
return;
}
let dir_path = match get_absolute_path(&dir) {
None => {
print_message(MessageType::ERROR, &format!("Cannot find dir: {}", dir));
return;
},
Some(path) => path,
};
match target.as_str() {
"huge" | "hugefile" => {
walk_dir(&dir_path, &|_, _| (), &|p| {
match p.metadata() {
Err(_) => (),
Ok(metadata) => {
let len = metadata.len();
if len > 100 * 1024 * 1024 {
print_lastline("");
//println!();
print_message(MessageType::OK, &format!("{:?}: {}", p, get_display_size(len as i64)));
}
},
}
}, &|p| {
match p.to_str() {
None => (),
Some(p_str) => print_lastline(&format!("Scanning: {}", p_str)),
}
true
}).unwrap_or(());
return;
},
_ => (),
}
// --------------------------------------------------------------------------------------------------------
println!("{:?}", get_home_path());
println!("{:?}", get_absolute_path("."));