Crates.io | zip-core |
lib.rs | zip-core |
version | 0.0.4 |
source | src |
created_at | 2024-06-27 19:41:36.683948 |
updated_at | 2024-08-22 11:04:41.98547 |
description | zip implementation independent structs and helpers |
homepage | https://gitlab.com/xMAC94x/zip-core |
repository | https://gitlab.com/xMAC94x/zip-core |
max_upload_size | |
id | 1286103 |
size | 132,736 |
Helper library to provide zip parsing according to PKWARE-APPNOT Version: 6.3.10
This library is intendent to be implementation independent, no_std basic functionality, structs/enum for zip crates.
By default std
is used, however it can be disabled via default-features = false
.
[local file header 1]
[encryption header 1]
[file data 1]
[data descriptor 1]
.
.
.
[local file header n]
[encryption header n]
[file data n]
[data descriptor n]
[archive decryption header]
[archive extra data record]
[central directory header 1]
.
.
.
[central directory header n]
[zip64 end of central directory record]
[zip64 end of central directory locator]
[end of central directory record]
You can use this crate to generate your own zip
parser.
Either because you are owner of the very good zip crate, or you want to build your own async version of it. Or you want to build your own zip parser, e.g. to extract as much data of a corupted file without any errors.
The nature of this crate is io
-less, we don't offer any functionality to load in a file, a stream or anything. except for bytes::Buf
if the parse
feature is enabled.
You can use this crate and provide your own io
logic around it, e.g. like:
let file = include_bytes!("example.zip");
let mut i = 0;
while let Some(local_occurence) = find_next_signature(
&file[i..],
core_zip::raw::CentralDirectoryHeaderFixed::CENTRAL_FILE_HEADER_SIGNATURE.to_le_bytes(),
) {
let occurence = i + local_occurence;
let mut buf = &file[occurence..];
if let Ok(f) = CentralDirectoryHeaderFixed::from_buf(&mut buf) {
println!("{:?}", std::str::from_utf8(&f.file_name));
}
i = occurence + 3;
}
You might see the std::str::from_utf8
, thats right, this crate doesn't even interpret the data in the records (except from some size values).
It provides some utilities, e.g. is_valid_signature
to check if the signature you parsed is correct, but it wont stop you from doing weird stuff with your zip.
You could also use this crate to craft your own zipbombs, posibilities are endless.
In case you wondered: the need for this crate came from the veloren
project, we want to upload our game without redownloading a whole zip, so we want to only download those parts where the crc missmatches.
See the documentation and the examples for more information on how to use this crate.