1 use std::io::{self, Read}; 2 main()3fn main() { 4 std::process::exit(real_main()); 5 } 6 real_main() -> i327fn real_main() -> i32 { 8 let stdin = io::stdin(); 9 let mut stdin_handle = stdin.lock(); 10 let mut buf = [0u8; 16]; 11 12 loop { 13 match zip::read::read_zipfile_from_stream(&mut stdin_handle) { 14 Ok(Some(mut file)) => { 15 println!( 16 "{}: {} bytes ({} bytes packed)", 17 file.name(), 18 file.size(), 19 file.compressed_size() 20 ); 21 match file.read(&mut buf) { 22 Ok(n) => println!("The first {} bytes are: {:?}", n, &buf[0..n]), 23 Err(e) => println!("Could not read the file: {e:?}"), 24 }; 25 } 26 Ok(None) => break, 27 Err(e) => { 28 println!("Error encountered while reading zip: {e:?}"); 29 return 1; 30 } 31 } 32 } 33 34 0 35 } 36