Cosmetics
parent
4cb09cd6a9
commit
5683a7d10c
11
src/main.rs
11
src/main.rs
|
@ -50,7 +50,7 @@ impl Args {
|
||||||
result = false;
|
result = false;
|
||||||
println!("Error, input ( {} ) is not a valid directory", self.input);
|
println!("Error, input ( {} ) is not a valid directory", self.input);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! Path::new(&self.output).exists() {
|
if ! Path::new(&self.output).exists() {
|
||||||
result = false;
|
result = false;
|
||||||
println!("Error, output ({} ) is not a valid directory", self.output);
|
println!("Error, output ({} ) is not a valid directory", self.output);
|
||||||
|
@ -66,10 +66,10 @@ impl Args {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_not_parent(&self) -> bool {
|
fn check_not_parent(&self) -> bool {
|
||||||
let vec = vec![&self.input, &self.output];
|
let vec = vec![&self.input, &self.output];
|
||||||
|
|
||||||
for (i, x) in vec.iter().enumerate() {
|
for (i, x) in vec.iter().enumerate() {
|
||||||
let mut a = Path::new(x);
|
let mut a = Path::new(x);
|
||||||
let tmp = match i {
|
let tmp = match i {
|
||||||
|
@ -173,7 +173,7 @@ fn main() {
|
||||||
// symlink_metadata does not follow symlink :-]
|
// symlink_metadata does not follow symlink :-]
|
||||||
let metadata = fs::symlink_metadata(entry.path()).unwrap();
|
let metadata = fs::symlink_metadata(entry.path()).unwrap();
|
||||||
let ft = metadata.file_type();
|
let ft = metadata.file_type();
|
||||||
|
|
||||||
if ft.is_file() {
|
if ft.is_file() {
|
||||||
if let Ok(mut file) = fs::File::open(&entry.path()) {
|
if let Ok(mut file) = fs::File::open(&entry.path()) {
|
||||||
process::<Sha256, _>(&mut file,
|
process::<Sha256, _>(&mut file,
|
||||||
|
@ -184,7 +184,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// let inputs = fs::read_dir(&args.input).unwrap();
|
// let inputs = fs::read_dir(&args.input).unwrap();
|
||||||
// for path in inputs {
|
// for path in inputs {
|
||||||
// let path_str = path.unwrap().path().into_os_string().into_string().unwrap();
|
// let path_str = path.unwrap().path().into_os_string().into_string().unwrap();
|
||||||
|
@ -208,6 +208,7 @@ fn main() {
|
||||||
fn process<D: Digest + Default, R: Read>(reader: &mut R, name: &str) {
|
fn process<D: Digest + Default, R: Read>(reader: &mut R, name: &str) {
|
||||||
let mut sh = D::default();
|
let mut sh = D::default();
|
||||||
let mut buffer = [0u8; BUFFER_SIZE];
|
let mut buffer = [0u8; BUFFER_SIZE];
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let n = match reader.read(&mut buffer) {
|
let n = match reader.read(&mut buffer) {
|
||||||
Ok(n) => n,
|
Ok(n) => n,
|
||||||
|
|
Loading…
Reference in New Issue