handle more zip errors

This commit is contained in:
SpikeHD
2022-05-15 16:55:06 -07:00
parent 75954e944b
commit f1b8fae4c9

View File

@@ -24,10 +24,22 @@ pub fn unzip(zipfile: &str, zippath: &str, destpath: &str) {
for i in 0..zip.len()
{
let mut file = zip.by_index(i).unwrap();
let mut file = match zip.by_index(i) {
Ok(file) => file,
Err(e) => {
println!("Could not open zip file: {}", e);
return;
}
};
println!("Filename: {}", file.name());
let first_byte = file.bytes().next().unwrap();
let first_byte = match file.bytes().next() {
Some(b) => b.unwrap(),
None => {
println!("File is empty: {}", &zipfile);
continue;
}
};
println!("{:?}", first_byte);
}
}