Expose zip file comment in ZipArchive

Resolves #71
This commit is contained in:
Mathijs van de Nes 2018-05-23 19:17:06 +02:00
parent 362f12dc9b
commit 00310c44d8

View file

@ -73,6 +73,7 @@ pub struct ZipArchive<R: Read + io::Seek>
files: Vec<ZipFileData>,
names_map: HashMap<String, usize>,
offset: u64,
comment: Vec<u8>,
}
enum ZipFileReader<'a> {
@ -193,6 +194,7 @@ impl<R: Read+io::Seek> ZipArchive<R>
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");
}
}