This library is a refactoring of the minizip contribution found in the zlib distribution that is supported on Windows, macOS, and Linux. It is based on the original work of Gilles Vollant that has been contributed to by many people over the years.
For the older release of the library checkout the 1.2 branch.
To generate the project files for your platform and IDE download and run cmake in the project directory.
cmake .
cmake --build .
| File(s) | Description | Required |
|---|---|---|
| miniunz.c | Sample unzip application | No |
| minizip.c | Sample zip application | No |
| mz_compat.* | Minizip 1.0 compatibility layer | No |
| mz.h | Error codes and flags | Yes |
| mz_os* | OS specific helper functions | Encryption |
| mz_strm.* | Stream interface | Yes |
| mz_strm_aes.* | WinZIP AES stream | No |
| mz_strm_buf.* | Buffered stream | No |
| mz_strm_bzip.* | BZIP2 stream using libbzip2 | No |
| mz_strm_crypt.* | PKWARE traditional encryption stream | No |
| mz_strm_lzma.* | LZMA stream using liblzma | No |
| mz_strm_mem.* | Memory stream | Yes |
| mz_strm_split.* | Disk splitting stream | No |
| mz_strm_posix.* | File stream using Posix functions | Non-windows systems |
| mz_strm_win32.* | File stream using Win32 API functions | Windows systems |
| mz_strm_zlib.* | Deflate stream using zlib | Yes |
| mz_unzip.* | Unzip functionality | Unzipping |
| mz_zip.* | Zip functionality | Zipping |
This library has been refactored around streams.
To unzip from a zip file in memory create a memory stream and pass it to the unzip open functions.
uint8_t *zip_buffer = NULL;
int32_t zip_buffer_size = 0;
void *mem_stream = NULL;
// fill zip_buffer with zip contents
mz_stream_mem_create(&mem_stream);
mz_stream_mem_set_buffer(mem_stream, zip_buffer, zip_buffer_size);
mz_stream_open(mem_stream, NULL, MZ_STREAM_MODE_READ);
void *unz_handle = mz_unzip_open(mem_stream);
// do unzip operations
mz_stream_mem_delete(&mem_stream);
To create a zip file in memory first create a growable memory stream and pass it to the zip open functions.
void *mem_stream = NULL;
mz_stream_mem_create(&mem_stream);
mz_stream_mem_set_grow(mem_stream, 1);
mz_stream_mem_set_grow_size(mem_stream, (128 * 1024));
mz_stream_open(mem_stream, NULL, MZ_STREAM_MODE_CREATE);
void *zip_handle = mz_zip_open(0, 0, mem_stream);
// do unzip operations
mz_stream_mem_delete(&mem_stream);