From 00310c44d8b6287abd721bfc0d5afa8e2f1779ee Mon Sep 17 00:00:00 2001 From: Mathijs van de Nes Date: Wed, 23 May 2018 19:17:06 +0200 Subject: [PATCH] Expose zip file comment in ZipArchive Resolves #71 --- src/read.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/read.rs b/src/read.rs index 9dfc7f38..749ff0e0 100644 --- a/src/read.rs +++ b/src/read.rs @@ -73,6 +73,7 @@ pub struct ZipArchive files: Vec, names_map: HashMap, offset: u64, + comment: Vec, } enum ZipFileReader<'a> { @@ -193,6 +194,7 @@ impl ZipArchive files: files, names_map: names_map, offset: archive_offset, + comment: footer.zip_file_comment, }) } @@ -502,4 +504,15 @@ mod test { let reader = ZipArchive::new(io::Cursor::new(v)).unwrap(); assert!(reader.len() == 1); } + + #[test] + fn zip_comment() { + use std::io; + use super::ZipArchive; + + let mut v = Vec::new(); + v.extend_from_slice(include_bytes!("../tests/data/mimetype.zip")); + let reader = ZipArchive::new(io::Cursor::new(v)).unwrap(); + assert!(reader.comment == b"zip-rs"); + } }