[![Crates.io](https://img.shields.io/crates/v/zip-core.svg?label=zip-core)](https://crates.io/crates/zip-core) [![docs.rs](https://docs.rs/zip-core/badge.svg)](https://docs.rs/zip-core) [![pipeline status](https://gitlab.com/xMAC94x/zip-core/badges/master/pipeline.svg)](https://gitlab.com/xMAC94x/zip-core/commits/master) [![coverage report](https://gitlab.com/xMAC94x/zip-core/badges/master/coverage.svg?min_good=90&min_acceptable=80)](https://gitlab.com/xMAC94x/zip-core/commits/master) [![license](https://img.shields.io/crates/l/zip-core)](https://gitlab.com/xMAC94x/zip-core/blob/master/LICENSE-MIT) [![dependencies](https://deps.rs/repo/gitlab/xMAC94x/zip-core/status.svg)](https://deps.rs/repo/gitlab/xMAC94x/zip-core) # zip-core Helper library to provide zip parsing according to [PKWARE-APPNOT Version: 6.3.10](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT) 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`. # zip ``` [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] ``` ## Usage 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: ```rust 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](https://docs.rs/zip-core) and the [examples](/examples) for more information on how to use this crate.