| 1 |
zip |
| 2 |
======== |
| 3 |
|
| 4 |
[](https://github.com/Pr0methean/zip/actions?query=branch%3Amaster+workflow%3ACI) |
| 5 |
[](https://crates.io/crates/zip) |
| 6 |
|
| 7 |
[Documentation](https://docs.rs/zip/latest/zip/) |
| 8 |
|
| 9 |
Info |
| 10 |
---- |
| 11 |
|
| 12 |
|
| 13 |
A zip library for rust which supports reading and writing of simple ZIP files. Formerly hosted at |
| 14 |
https://github.com/zip-rs/zip2. |
| 15 |
|
| 16 |
Supported compression formats: |
| 17 |
|
| 18 |
* stored (i.e. none) |
| 19 |
* deflate |
| 20 |
* deflate64 (decompression only) |
| 21 |
* bzip2 |
| 22 |
* zstd |
| 23 |
* lzma (decompression only) |
| 24 |
|
| 25 |
Currently unsupported zip extensions: |
| 26 |
|
| 27 |
* Multi-disk |
| 28 |
|
| 29 |
Features |
| 30 |
-------- |
| 31 |
|
| 32 |
The features available are: |
| 33 |
|
| 34 |
* `aes-crypto`: Enables decryption of files which were encrypted with AES. Supports AE-1 and AE-2 methods. |
| 35 |
* `deflate`: Enables compressing and decompressing an unspecified implementation (that may change in future versions) of |
| 36 |
the deflate compression algorithm, which is the default for zip files. Supports compression quality 1..=264. |
| 37 |
* `deflate-flate2`: Combine this with any `flate2` feature flag that enables a back-end, to support deflate compression |
| 38 |
at quality 1..=9. |
| 39 |
* `deflate-zopfli`: Enables deflating files with the `zopfli` library (used when compression quality is 10..=264). This |
| 40 |
is the most effective `deflate` implementation available, but also among the slowest. |
| 41 |
* `deflate64`: Enables the deflate64 compression algorithm. Only decompression is supported. |
| 42 |
* `lzma`: Enables the LZMA compression algorithm. Only decompression is supported. |
| 43 |
* `bzip2`: Enables the BZip2 compression algorithm. |
| 44 |
* `time`: Enables features using the [time](https://github.com/rust-lang-deprecated/time) crate. |
| 45 |
* `chrono`: Enables converting last-modified `zip::DateTime` to and from `chrono::NaiveDateTime`. |
| 46 |
* `zstd`: Enables the Zstandard compression algorithm. |
| 47 |
|
| 48 |
By default `aes-crypto`, `bzip2`, `deflate`, `deflate64`, `lzma`, `time` and `zstd` are enabled. |
| 49 |
|
| 50 |
The following feature flags are deprecated: |
| 51 |
|
| 52 |
* `deflate-miniz`: Use `flate2`'s default backend for compression. Currently the same as `deflate`. |
| 53 |
|
| 54 |
MSRV |
| 55 |
---- |
| 56 |
|
| 57 |
Our current Minimum Supported Rust Version is **1.73**. When adding features, |
| 58 |
we will follow these guidelines: |
| 59 |
|
| 60 |
- We will always support the latest four minor Rust versions. This gives you a 6 |
| 61 |
month window to upgrade your compiler. |
| 62 |
- Any change to the MSRV will be accompanied with a **minor** version bump. |
| 63 |
|
| 64 |
Examples |
| 65 |
-------- |
| 66 |
|
| 67 |
See the [examples directory](examples) for: |
| 68 |
* How to write a file to a zip. |
| 69 |
* How to write a directory of files to a zip (using [walkdir](https://github.com/BurntSushi/walkdir)). |
| 70 |
* How to extract a zip file. |
| 71 |
* How to extract a single file from a zip. |
| 72 |
* How to read a zip from the standard input. |
| 73 |
* How to append a directory to an existing archive |
| 74 |
|
| 75 |
Fuzzing |
| 76 |
------- |
| 77 |
|
| 78 |
Fuzzing support is through [cargo fuzz](https://github.com/rust-fuzz/cargo-fuzz). To install cargo fuzz: |
| 79 |
|
| 80 |
```bash |
| 81 |
cargo install cargo-fuzz |
| 82 |
``` |
| 83 |
|
| 84 |
To list fuzz targets: |
| 85 |
|
| 86 |
```bash |
| 87 |
cargo +nightly fuzz list |
| 88 |
``` |
| 89 |
|
| 90 |
To start fuzzing zip extraction: |
| 91 |
|
| 92 |
```bash |
| 93 |
cargo +nightly fuzz run fuzz_read |
| 94 |
``` |
| 95 |
|
| 96 |
To start fuzzing zip creation: |
| 97 |
|
| 98 |
```bash |
| 99 |
cargo +nightly fuzz run fuzz_write |
| 100 |
``` |