1 use std::io::prelude::*; 2 main()3fn main() { 4 std::process::exit(real_main()); 5 } 6 real_main() -> i327fn real_main() -> i32 { 8 let args: Vec<_> = std::env::args().collect(); 9 if args.len() < 2 { 10 println!("Usage: {} <filename>", args[0]); 11 return 1; 12 } 13 let fname = std::path::Path::new(&*args[1]); 14 let zipfile = std::fs::File::open(fname).unwrap(); 15 16 let mut archive = zip::ZipArchive::new(zipfile).unwrap(); 17 18 let mut file = match archive.by_name("test/lorem_ipsum.txt") { 19 Ok(file) => file, 20 Err(..) => { 21 println!("File test/lorem_ipsum.txt not found"); 22 return 2; 23 } 24 }; 25 26 let mut contents = String::new(); 27 file.read_to_string(&mut contents).unwrap(); 28 println!("{contents}"); 29 30 0 31 } 32