1 use std::fs; 2 use std::io::BufReader; 3 main()4fn main() { 5 std::process::exit(real_main()); 6 } 7 real_main() -> i328fn real_main() -> i32 { 9 let args: Vec<_> = std::env::args().collect(); 10 if args.len() < 2 { 11 println!("Usage: {} <filename>", args[0]); 12 return 1; 13 } 14 let fname = std::path::Path::new(&*args[1]); 15 let file = fs::File::open(&fname).unwrap(); 16 let reader = BufReader::new(file); 17 18 let mut archive = zip::ZipArchive::new(reader).unwrap(); 19 20 for i in 0..archive.len() { 21 let file = archive.by_index(i).unwrap(); 22 let outpath = file.sanitized_name(); 23 24 { 25 let comment = file.comment(); 26 if !comment.is_empty() { 27 println!("Entry {} comment: {}", i, comment); 28 } 29 } 30 31 if (&*file.name()).ends_with('/') { 32 println!("Entry {} is a directory with name \"{}\"", i, outpath.as_path().display()); 33 } else { 34 println!("Entry {} is a file with name \"{}\" ({} bytes)", i, outpath.as_path().display(), file.size()); 35 } 36 } 37 return 0; 38 } 39