需 CMake 3.11 或更高版本;BZIP2、LZMA、PPMD、ZSTD 等第三方库按 CMake 选项启用,未安装时需开启 MZ_FETCH_LIBS 自动拉取源码编译;单元测试需额外加 -D MZ_BUILD_UNIT_TESTS=ON 并用 ctest 运行
minizip-ng
zlib-ng活跃维护zlib 官方发行版里 minizip 的增强分支,支持 bzip2、lzma、WinZip AES 加密和分卷压缩,跨平台处理 zip 读写。
Fork of the popular zip manipulation library found in the zlib distribution.
cmake -S . -B build -D MZ_BUILD_TESTS=ON
cmake --build buildREADME 未说明;仅声明支持 Windows、macOS 和 Linux 平台
C 语言 zip 操作库,重构自 zlib 自带 minizip,补上长期缺失的新特性与修复
zlib 官方发行版里 minizip 的增强分支,支持 bzip2、lzma、WinZip AES 加密和分卷压缩,跨平台处理 zip 读写。
核心能力
- 创建、解压、增删 zip 条目并读写原始条目数据
- 支持 ZIP64 大文件与内存中读写归档
- 支持 Zlib、BZIP2、LZMA、PPMD、XZ、ZSTD 多种压缩
- 提供 PKWARE 传统加密与 WinZIP AES 密码保护
- 支持分卷、符号链接、NTFS 时间戳与 UTF-8 文件名
容易踩的坑
- 4.2.2最新正式版2026-06-30 · 2026-06-30 16:45 UTC
What's Changed
- build(deps): bump actions/download-artifact from 7 to 8 by @dependabot[bot] in https://github.com/zlib-ng/minizip-ng/pull/990
- build(deps): bump actions/upload-artifact from 6 to 7 by @dependabot[bot] in https://github.com/zlib-ng/minizip-ng/pull/991
- fix: warning: '=': narrowing conversion, possible loss of data by @sergio-nsk in https://github.com/zlib-ng/minizip-ng/pull/994
- docs: update memory stream test link by @SSDWGG in https://github.com/zlib-ng/minizip-ng/pull/999
- fix: mz_crypt_aes_set_*_key for GCM on OpenSSL by @sergio-nsk in https://github.com/zlib-ng/minizip-ng/pull/1002
- test: improve: validate cipher bytes after encryption by @sergio-nsk in https://github.com/zlib-ng/minizip-ng/pull/1003
- fix: reject symlink targets that escape extraction dir by @nmoinvaz in https://github.com/zlib-ng/minizip-ng/pull/1005
New Contributors
- @SSDWGG made their first contribution in https://github.com/zlib-ng/minizip-ng/pull/999
Full Changelog: https://github.com/zlib-ng/minizip-ng/compare/4.2.1...4.2.2
- 4.2.12026-04-27 · 2026-04-27 19:24 UTC
查看更新说明
What's Changed
- cmake: pick zstd and zlib-ng targets per BUILD_SHARED_LIBS by @nmoinvaz in https://github.com/zlib-ng/minizip-ng/pull/989
Full Changelog: https://github.com/zlib-ng/minizip-ng/compare/4.2.0...4.2.1
- 4.2.02026-04-27 · 2026-04-27 01:57 UTC
查看更新说明
What's Changed
- cmake: produce portable installed package config by @nmoinvaz in https://github.com/zlib-ng/minizip-ng/pull/983
- mz_os: fix symlink check at or above destination dir by @nmoinvaz in https://github.com/zlib-ng/minizip-ng/pull/984
- test: skip AES-GCM test when build doesn't support it by @nmoinvaz in https://github.com/zlib-ng/minizip-ng/pull/986
- minizip: place erase temp on same filesystem when TMPDIR differs by @nmoinvaz in https://github.com/zlib-ng/minizip-ng/pull/985
- mz_os: split file and link attribute getters (#797) by @nmoinvaz in https://github.com/zlib-ng/minizip-ng/pull/987
- compat: add unzGetCurrentFileZStreamPos64 by @nmoinvaz in https://github.com/zlib-ng/minizip-ng/pull/988
Full Changelog: https://github.com/zlib-ng/minizip-ng/compare/4.1.2...4.2.0
- 4.1.22026-04-25 · 2026-04-25 05:51 UTC
查看更新说明
What's Changed
- cmake: fix: mz_config.h was missing in install target (#980) by @sergio-nsk in https://github.com/zlib-ng/minizip-ng/pull/981
- cmake: various clean ups by @nmoinvaz in https://github.com/zlib-ng/minizip-ng/pull/982
Full Changelog: https://github.com/zlib-ng/minizip-ng/compare/4.1.1...4.1.2
- 4.1.12026-04-23 · 2026-04-23 04:12 UTC
查看更新说明
What's Changed
- mz_strm_ppmd.c reader issue: it can't detect EOF by @pmqs in https://github.com/zlib-ng/minizip-ng/pull/953
- Add PPMd & Zstd zip files to the fuzz corpus by @pmqs in https://github.com/zlib-ng/minizip-ng/pull/954
- Document that mz_zip_tm_to_time_t requires a year-1900 indexed time struct. by @Coeur in https://github.com/zlib-ng/minizip-ng/pull/951
- build: avoid MIN macro for Windows by @Coeur in https://github.com/zlib-ng/minizip-ng/pull/949
- Document PPMD compression by @pmqs in https://github.com/zlib-ng/minizip-ng/pull/958
- Remove calls to
add_subdirectoryinCMakeLists.txtfor lzma & zlib by @pmqs in https://github.com/zlib-ng/minizip-ng/pull/959 - update to use ppmd from 7zip 26.00 by @pmqs in https://github.com/zlib-ng/minizip-ng/pull/967
- Set default value for MZ_SANITIZER to OFF in README.md by @pmqs in https://github.com/zlib-ng/minizip-ng/pull/964
- Replace ZLIB_ENABLE_TESTS with BUILD_TESTING by @pmqs in https://github.com/zlib-ng/minizip-ng/pull/965
- Fix integer overflow in split stream write for disk sizes > 2GB by @nmoinvaz in https://github.com/zlib-ng/minizip-ng/pull/969
- Restore ability to prefer OpenSSL over BCrypt on Windows by @solbjorn in https://github.com/zlib-ng/minizip-ng/pull/975
- improve: support for more platforms by @sergio-nsk in https://github.com/zlib-ng/minizip-ng/pull/977
- cmake: improve: mz.h, mz_os.h are public API, shouldn't rely on user -D by @sergio-nsk in https://github.com/zlib-ng/minizip-ng/pull/978
- Fix two bugs causing premature exiting the PPMd decompression by @solbjorn in https://github.com/zlib-ng/minizip-ng/pull/976
- Harden the cmake Address Sanitizer detection code. by @pmqs in https://github.com/zlib-ng/minizip-ng/pull/960
Dependabot
- Ppmd dependabot by @pmqs in https://github.com/zlib-ng/minizip-ng/pull/947
- Bump actions/upload-artifact from 6 to 7 by @dependabot[bot] in https://github.com/zlib-ng/minizip-ng/pull/962
- Bump svenstaro/upload-release-action from 2.11.4 to 2.11.5 by @dependabot[bot] in https://github.com/zlib-ng/minizip-ng/pull/974
- Bump svenstaro/upload-release-action from 2.11.3 to 2.11.4 by @dependabot[bot] in https://github.com/zlib-ng/minizip-ng/pull/963
- Bump codecov/codecov-action from 5 to 6 by @dependabot[bot] in https://github.com/zlib-ng/minizip-ng/pull/973
New Contributors
- @solbjorn made their first contribution in https://github.com/zlib-ng/minizip-ng/pull/975
Full Changelog: https://github.com/zlib-ng/minizip-ng/compare/4.1.0...4.1.1
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
minizip-ng
minizip-ng is a zip manipulation library written in C that is supported on Windows, macOS, and Linux.
Developed and maintained by Nathan Moinvaziri.
Branches
| Name | Description |
|---|---|
| develop | Latest development code. |
| master | Most recent stable release. |
| 1.2 | Old changes to original minizip that includes WinZip AES encryption, disk splitting, I/O buffering and some additional fixes. Not ABI compatible with original minizip. |
| 1.1 | Original minizip as of zlib 1.2.11. |
History
Minizip was originally developed by Gilles Vollant in 1998. It was first included in the zlib distribution as an additional code contribution starting in zlib 1.1.2. Since that time, it has been continually improved upon and contributed to by many people. The original project can still be found in the zlib distribution that is maintained by Mark Adler.
The motivation behind this repository has been the need for new features and bug fixes to the original library which had not been maintained for a long period of time. The code has been largely refactored and rewritten in order to help improve maintainability and readability. A compatibility layer has been provided for consumers of the original minizip library.
Features
- Creating and extracting zip archives.
- Adding and removing entries from zip archives.
- Read and write raw zip entry data.
- Reading and writing zip archives from memory.
- Support for large files with ZIP64 extension.
- Zlib, BZIP2, LZMA, PPMD, XZ and ZSTD compression methods.
- Password protection through Traditional PKWARE and WinZIP AES encryption.
- Buffered streaming for improved I/O performance.
- NTFS timestamp support for UTC last modified, last accessed, and creation dates.
- Disk split support for splitting zip archives into multiple files.
- Preservation of file attributes across file systems.
- Follow and store symbolic links.
- Unicode filename support through UTF-8 encoding.
- Legacy character encoding support CP437, CP932, CP936, CP950.
- Turn off compilation of compression, decompression, or encryption.
- Windows (Win32 & WinRT), macOS and Linux platform support.
- Streaming interface for easy implementation of additional platforms.
- Support for Apple's compression library ZLIB and XZ implementations.
- Zero out local file header information.
- Zip/unzip of central directory to reduce size.
- Recover the central directory if it is corrupt or missing.
- Example minizip and minigzip command line tools.
Build
To generate project files for your platform:
- Download and install cmake (version 3.11 or later recommended).
- Run cmake in the minizip directory.
cmake -S . -B build -D MZ_BUILD_TESTS=ON
cmake --build build
Build Options
| Name | Description | Default Value |
|---|---|---|
| MZ_COMPAT | Enables compatibility layer | ON |
| MZ_ZLIB | Enables ZLIB compression | ON |
| MZ_ZLIB_FLAVOR | Select ZLIB implementation (auto, zlib-ng, zlib) | auto |
| MZ_BZIP2 | Enables BZIP2 compression | ON |
| MZ_LZMA | Enables LZMA & XZ compression | ON |
| MZ_PPMD | Enables PPMD compression | ON |
| MZ_ZSTD | Enables ZSTD compression | ON |
| MZ_LIBCOMP | Enables Apple compression | APPLE |
| MZ_FETCH_LIBS | Enables fetching third-party libraries if not found | WIN32 |
| MZ_FORCE_FETCH_LIBS | Enables fetching third-party libraries always | OFF |
| MZ_PKCRYPT | Enables PKWARE traditional encryption | ON |
| MZ_WZAES | Enables WinZIP AES encryption | ON |
| MZ_OPENSSL | Enables OpenSSL encryption | UNIX |
| MZ_LIBBSD | Builds with libbsd crypto random | UNIX |
| MZ_ICONV | Enables iconv encoding conversion | ON |
| MZ_ICU | Enables ICU encoding conversion | OFF |
| MZ_COMPRESS_ONLY | Only support compression | OFF |
| MZ_DECOMPRESS_ONLY | Only support decompression | OFF |
| MZ_FILE32_API | Builds using posix 32-bit file api | OFF |
| MZ_BUILD_TESTS | Builds minizip test executable | OFF |
| MZ_BUILD_UNIT_TESTS | Builds minizip unit test project | OFF |
| MZ_BUILD_FUZZ_TESTS | Builds minizip fuzz executables | OFF |
| MZ_CODE_COVERAGE | Build with code coverage flags | OFF |
| MZ_SANITIZER | Build with code sanitizer (Memory, Thread, Address, Undefined) | OFF |
| MZ_LIB_SUFFIX | Library name suffix for packaging |
Test
Unit tests are written in C++ with Google Test.
cmake -S . -B build -D MZ_BUILD_TESTS=ON -D MZ_BUILD_UNIT_TESTS=ON
cmake --build build
ctest --test-dir build --output-on-failure
Lint
Pull requests are checked with clang-format 19 using the rules in .clang-format.
git clang-format --diff --commit=origin/develop
Third-Party Libraries
Third-party libraries may be required based on the CMake options selected. If the system already has the library
installed then it will be used, otherwise CMake will retrieve the source code for the library from its official git repository and compile it in when the MZ_FETCH_LIBS option is enabled.
| Project | License | CMake Option | Comments |
|---|---|---|---|
| bzip2 | license | MZ_BZIP2 | Written by Julian Seward. |
| liblzma | Public domain | MZ_LZMA | Written by Igor Pavlov and Lasse Collin. |
| ppmd | Public domain | MZ_PPMD | Written by Igor Pavlov. |
| zlib | zlib | MZ_ZLIB | Written by Mark Adler and Jean-loup Gailly. Or alternatively, zlib-ng by Hans Kristian Rosbach. |
| zstd | BSD | MZ_ZSTD | Written by Facebook. |
This project uses the zlib license.
Acknowledgments
Thanks go out to all the people who have taken the time to contribute code reviews, testing and/or patches. This project would not have been as good without you.
Thanks to Gilles Vollant on which this work is originally based on.
The ZIP format was defined by Phil Katz of PKWARE.