Open a zip archive, parse zip entries metadata and read raw content.
More...
#include <Zip.hpp>
|
enum class | Encryption { None
, Traditional
, Unsupported
} |
| Encryption algorithm. More...
|
enum class | Compression {
Store = 0
, Shrink = 1
, Implode = 6
, Deflate = 8
,
Deflate64 = 9
, BZip2 = 12
, LZMA = 14
, Zstandard = 93
,
MP3 = 94
, XZ = 95
, JPEG = 96
, WavPack = 97
,
PPMd = 98
} |
| Compression algorithm. More...
|
|
| Zip (std::istream &stream) |
| Open a zip archive from an already opened input stream.
|
| Zip (const std::string &filename) |
| Open a zip archive from a file.
|
auto | begin () const -> Iterator |
| Get an iterator pointing to the first entry.
|
auto | end () const -> Iterator |
| Get an end-of-stream iterator.
|
auto | operator[] (const std::string &name) const -> Entry |
| Get the first entry having the given name.
|
auto | operator[] (std::size_t index) const -> Entry |
| Get the entry at the given index.
|
auto | seek (const Entry &entry) const -> std::istream & |
| Set the underlying stream's input position indicator at the beginning the given entry's raw data.
|
auto | load (const Entry &entry, std::size_t count=std::numeric_limits< std::size_t >::max()) const -> std::vector< std::uint8_t > |
| Load at most count bytes of the given entry's raw data.
|
void | changeKeys (std::ostream &os, const Keys &oldKeys, const Keys &newKeys, Progress &progress) const |
| Copy the zip file into os changing the encrypted data using the given keys.
|
void | decrypt (std::ostream &os, const Keys &keys, Progress &progress) const |
| Copy the zip file into os removing encryption using the given keys.
|
Open a zip archive, parse zip entries metadata and read raw content.
- Note
- Zip64 extensions are supported.
- Known limitations
Spanned or split zip files are not supported.
Strong encryption (SES) is not supported. In particular, central directory encryption is not supported.
Language Encoding (EFS) is not supported. (APPNOTE.TXT, Appendix D)
- See also
- APPNOTE.TXT
◆ Compression
Compression algorithm.
- Note
- This enumeration is not exhaustive.
◆ Encryption
Encryption algorithm.
Enumerator |
---|
None | No encryption.
|
Traditional | Traditional PKWARE encryption (ZipCrypto), vulnerable to known plaintext attack.
|
Unsupported | Other encryption (DES, RC2, 3DES, AES, Blowfish, Twofish, RC4)
|
◆ Zip() [1/2]
Zip::Zip |
( |
std::istream & | stream | ) |
|
|
explicit |
Open a zip archive from an already opened input stream.
- Exceptions
-
Error | if the given input stream is not a valid zip archive |
◆ Zip() [2/2]
Zip::Zip |
( |
const std::string & | filename | ) |
|
|
explicit |
Open a zip archive from a file.
- Exceptions
-
FileError | if the file cannot be opened |
Error | if the opened file is not a valid zip archive |
◆ changeKeys()
void Zip::changeKeys |
( |
std::ostream & | os, |
|
|
const Keys & | oldKeys, |
|
|
const Keys & | newKeys, |
|
|
Progress & | progress ) const |
Copy the zip file into os changing the encrypted data using the given keys.
- Exceptions
-
Error | if the archive is not a valid zip archive |
◆ checkEncryption()
Check that the given entry uses the expected encryption algorithm.
- Exceptions
-
Error | if the given entry does not use the expected encryption algorithm |
◆ decrypt()
void Zip::decrypt |
( |
std::ostream & | os, |
|
|
const Keys & | keys, |
|
|
Progress & | progress ) const |
Copy the zip file into os removing encryption using the given keys.
- Exceptions
-
Error | if the archive is not a valid zip archive |
◆ load()
auto Zip::load |
( |
const Entry & | entry, |
|
|
std::size_t | count = std::numeric_limits< std::size_t >::max() ) const -> std::vector< std::uint8_t > |
Load at most count bytes of the given entry's raw data.
- Exceptions
-
Error | if the given entry's data is not at the expected offset |
◆ operator[]() [1/2]
auto Zip::operator[] |
( |
const std::string & | name | ) |
const -> Entry |
Get the first entry having the given name.
- Exceptions
-
Error | if the archive does not contain an entry with the given name |
◆ operator[]() [2/2]
auto Zip::operator[] |
( |
std::size_t | index | ) |
const -> Entry |
Get the entry at the given index.
- Exceptions
-
Error | if the index is out of bounds |
◆ seek()
auto Zip::seek |
( |
const Entry & | entry | ) |
const -> std::istream & |
Set the underlying stream's input position indicator at the beginning the given entry's raw data.
- Exceptions
-
Error | if the given entry's data is not at the expected offset |
The documentation for this class was generated from the following file: