Added windows install instructions #269
1 file changed
tree: 48b2d094eb286c397fe7268c2472c9357af9258a
  1. lib/
  2. test/
  3. .travis.yml
  4. CMakeLists.txt
  5. LICENSE
  6. minizip.c
  7. minizip.pc.cmakein
  8. Minizip.podspec
  9. mz.h
  10. mz_compat.c
  11. mz_compat.h
  12. mz_os.c
  13. mz_os.h
  14. mz_os_posix.c
  15. mz_os_posix.h
  16. mz_os_win32.c
  17. mz_os_win32.h
  18. mz_strm.c
  19. mz_strm.h
  20. mz_strm_aes.c
  21. mz_strm_aes.h
  22. mz_strm_buf.c
  23. mz_strm_buf.h
  24. mz_strm_bzip.c
  25. mz_strm_bzip.h
  26. mz_strm_lzma.c
  27. mz_strm_lzma.h
  28. mz_strm_mem.c
  29. mz_strm_mem.h
  30. mz_strm_pkcrypt.c
  31. mz_strm_pkcrypt.h
  32. mz_strm_posix.c
  33. mz_strm_posix.h
  34. mz_strm_split.c
  35. mz_strm_split.h
  36. mz_strm_win32.c
  37. mz_strm_win32.h
  38. mz_strm_zlib.c
  39. mz_strm_zlib.h
  40. mz_zip.c
  41. mz_zip.h
  42. README.md
README.md

Minizip 2.3.3

This library is a refactoring of the minizip contribution found in the zlib distribution and is supported on Windows, macOS, and Linux. The motivation for this work has been the inclusion of advanced features, improvements in code maintainability and readability, and the reduction of duplicate code. It is based on the original work of Gilles Vollant that has been contributed to by many people over the years.

Dev: Dev Branch Status Master: Master Branch Status

For my older fork of this library checkout the 1.2 branch. For the original work maintained by Mark Adler checkout the zlib minizip contrib.

Build

To generate project files for your platform:

  1. Download and install cmake.
  2. Download and install zlib if it is not installed on your system.
  3. Run cmake in the minizip directory.
cmake . -DBUILD_TEST=ON
cmake --build .

Zlib Installation (Windows)

Option 1. Install the zlib package to the Program Files directory with an Administrator command prompt.

cmake . -DCMAKE_INSTALL_PREFIX=%PROGRAMFILES%\zlib
cmake --build . --config Release --target INSTALL

Option 2. Compile zlib in minizip's lib directory.

cmake .
cmake --build . --config Release

Navigate back to the minizip directory and before building run:

cmake . -DZLIB_LIBRARY=lib\zlib\release\zlibstatic.lib -DZLIB_INCLUDE_DIR=lib\zlib\

Build Options

NameDescriptionDefault Value
USE_ZLIBEnables ZLIB compressionON
USE_BZIP2Enables BZIP2 compressionON
USE_LZMAEnables LZMA compressionON
USE_PKCRYPTEnables PKWARE traditional encryptionON
USE_AESEnables AES encryptionON
BUILD_TESTBuilds minizip test executableOFF

Contents

File(s)DescriptionRequired
minizip.cSample applicationNo
mz_compat.*Minizip 1.0 compatibility layerNo
mz.hError codes and flagsYes
mz_os*OS specific helper functionsEncryption, Disk Splitting
mz_strm.*Stream interfaceYes
mz_strm_aes.*WinZIP AES streamNo
mz_strm_buf.*Buffered streamNo
mz_strm_bzip.*BZIP2 stream using libbzip2No
mz_strm_lzma.*LZMA stream using liblzmazlib or liblzma
mz_strm_mem.*Memory streamYes
mz_strm_split.*Disk splitting streamNo
mz_strm_pkcrypt.*PKWARE traditional encryption streamNo
mz_strm_posix.*File stream using Posix functionsNon-windows systems
mz_strm_win32.*File stream using Win32 API functionsWindows systems
mz_strm_zlib.*Deflate stream using zlibzlib or liblzma
mz_zip.*Zip functionalityYes

Features

Compression Methods

BZIP2

  • Requires cmake . -DUSE_BZIP2=ON or #define HAVE_BZIP2
  • Requires BZIP2 library

LZMA

  • Requires cmake . -DUSE_LZMA=ON or #define HAVE_LZMA
  • Requires liblzma library

Encryption

WinZIP AES Encryption

  • Requires cmake . -DUSE_AES=ON or #define HAVE_AES
  • Requires Brian Gladman's AES and SHA libraries

When zipping with a password it will always use AES 256-bit encryption. When unzipping it will use AES decryption only if necessary.

Disabling All Encryption

To disable encryption use the following cmake commands:

cmake . -DUSE_AES=OFF
cmake . -DUSE_PKCRYPT=OFF

NTFS Timestamps

Support has been added for UTC last modified, last accessed, and creation dates.

Streams

This library has been refactored around streams.

Memory Streaming

To unzip from a zip file in memory pass the memory stream to the open function.

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_OPEN_MODE_READ);

void *zip_handle = mz_zip_open(mem_stream, MZ_OPEN_MODE_READ);
// 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 open function.

void *mem_stream = NULL;

mz_stream_mem_create(&mem_stream);
mz_stream_mem_set_grow_size(mem_stream, (128 * 1024));
mz_stream_open(mem_stream, NULL, MZ_OPEN_MODE_CREATE);

void *zip_handle = mz_zip_open(mem_stream, MZ_OPEN_MODE_WRITE);
// do unzip operations

mz_stream_mem_delete(&mem_stream);

For a complete example, see test_zip_mem() in test.c.

Buffered Streaming

By default the library will read bytes typically one at a time. The buffered stream allows for buffered read and write operations to improve I/O performance.

void *stream = NULL;
void *buf_stream = NULL;

mz_stream_os_create(&stream)
// do open os stream

mz_stream_buffered_create(&buf_stream);
mz_stream_buffered_open(buf_stream, NULL, MZ_OPEN_MODE_READ);
mz_stream_buffered_set_base(buf_stream, stream);

void *zip_handle = mz_zip_open(buf_stream, MZ_OPEN_MODE_READ);

Disk Splitting Stream

To create an archive with multiple disks use the disk splitting stream and supply a disk size value in bytes.

void *stream = NULL;
void *split_stream = NULL;

mz_stream_os_create(&stream);

mz_stream_split_create(&split_stream);
mz_stream_split_set_prop_int64(split_stream, MZ_STREAM_PROP_DISK_SIZE, 64 * 1024);

mz_stream_set_base(split_stream, stream);

mz_stream_open(split_stream, path..

void *zip_handle = mz_zip_open(split_stream, MZ_OPEN_MODE_WRITE);

Windows RT

  • Requires #define MZ_USE_WINRT_API

Limitations

  • Archives are required to have a central directory.
  • Central directory header values should be correct and it is necessary for the compressed size to be accurate for AES encryption.
  • Central directory encryption is not supported due to licensing restrictions mentioned by PKWARE in their zip appnote.
  • Central directory is the only data stored on the last disk of a split-disk archive and doesn't follow disk size restrictions.