Compute hash for both directory and store result in a vec

master
Benoît 2018-05-02 23:12:18 +02:00
parent 583d7f1b9c
commit f97430c21a
1 changed files with 32 additions and 43 deletions

View File

@ -65,9 +65,7 @@ impl Args {
}
fn check_not_parent(&self) -> bool {
let vec = vec![&self.input, &self.output];
for (i, x) in vec.iter().enumerate() {
for (i, x) in vec![&self.input, &self.output].iter().enumerate() {
let mut a = Path::new(x);
let tmp = match i {
0 => &self.output,
@ -172,16 +170,15 @@ fn main() {
t.fg(term::color::GREEN).unwrap();
let args = Args::new(&matches);
if args.vlevel >= 2 {
println!("Value for input: {}", args.input);
println!("Value for output: {}", args.output);
println!("Verbosity Level: {}", args.vlevel);
if args.dryrun {
println!("dry-run enabled");
} else if args.vlevel >= 2 {
t.fg(term::color::RED).unwrap();
println!("dry-run not enabled");
t.reset().unwrap();
}
}
// Check input & output
@ -203,8 +200,9 @@ fn main() {
process::exit(1);
}
// Output
for entry in WalkDir::new(&args.output)
// Walk through path 1 & 2 [Todo: threading]
for s in &[&args.input, &args.output] {
for entry in WalkDir::new(&s)
.into_iter()
.filter_map(|e| e.ok())
{
@ -220,28 +218,19 @@ fn main() {
hash: vec![],
realpath: String::from("TODO"),
};
// compute file hash
a.hash::<Sha256, _>(&mut file);
println!("{}", a);
files_candidate.push(a);
}
}
}
}
for i in files_candidate {
println!("{}", i);
}
// let inputs = fs::read_dir(&args.input).unwrap();
// for path in inputs {
// let path_str = path.unwrap().path().into_os_string().into_string().unwrap();
// println!("[I] Name: {}", path_str);
// if let Ok(mut file) = fs::File::open(&path_str) {
// process::<Sha256, _>(&mut file,
// &path_str);
// }
// }
t.reset().unwrap();
t.fg(term::color::CYAN).unwrap();
println!("Cheers !");