{"id":13645902,"url":"https://github.com/sebastiandev/zipper","last_synced_at":"2025-04-21T17:31:32.488Z","repository":{"id":2259945,"uuid":"38395510","full_name":"sebastiandev/zipper","owner":"sebastiandev","description":"C++ wrapper around minizip compression library","archived":false,"fork":false,"pushed_at":"2024-04-22T07:08:20.000Z","size":505,"stargazers_count":518,"open_issues_count":1,"forks_count":124,"subscribers_count":29,"default_branch":"master","last_synced_at":"2024-11-09T19:39:44.593Z","etag":null,"topics":["compression","compression-library","cpp","minizip","minizip-compression-library","zlib"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebastiandev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-01T21:16:36.000Z","updated_at":"2024-11-02T01:32:57.000Z","dependencies_parsed_at":"2024-08-02T01:38:29.106Z","dependency_job_id":null,"html_url":"https://github.com/sebastiandev/zipper","commit_stats":{"total_commits":147,"total_committers":26,"mean_commits":5.653846153846154,"dds":0.6394557823129252,"last_synced_commit":"87b14a4b31771ed94ebb3204dc6ed69ad9c78436"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastiandev%2Fzipper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastiandev%2Fzipper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastiandev%2Fzipper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastiandev%2Fzipper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebastiandev","download_url":"https://codeload.github.com/sebastiandev/zipper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250100449,"owners_count":21374944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compression","compression-library","cpp","minizip","minizip-compression-library","zlib"],"created_at":"2024-08-02T01:02:44.658Z","updated_at":"2025-04-21T17:31:32.137Z","avatar_url":"https://github.com/sebastiandev.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":":warning: **This project and particularly this master branch is no longer maintained. The new repo is:**\nhttps://github.com/Lecrapouille/zipper based on https://github.com/sebastiandev/zipper/tree/v2.x.y\n\n![Zipper](https://github.com/sebastiandev/zipper/blob/master/logo.png)\n\nC++ wrapper around minizip compression library\n\n**Zipper**'s goal is to bring the power and simplicity of minizip to a more object oriented/c++ user friendly library.\nIt was born out of the necessity of a compression library that would be reliable, simple and flexible.\nBy flexibility I mean supporting all kinds of inputs and outputs, but specifically been able to compress into memory instead of been restricted to file compression only, and using data from memory instead of just files as well.\n\n### Features\n\n- [x] Create zip in memory.\n- [x] Allow files, vector and generic streams as input to zip.\n- [x] File mappings for replacing strategies (overwrite if exists or use alternative name from mapping).\n- [x] Password protected zip (EAS).\n- [x] Multi platform.\n\n\n### :warning: Security Notice\nZipper currently follows an unmaintaind and vulnerable version of the minizip library.\nIt is vulnerable to ZipSlip attack and mitigations should be put in place by Zipper's users.\n\n\u003e References:\n\u003e\n\u003e [ZipSlip](https://snyk.io/research/zip-slip-vulnerability),\n\u003e [CVE-2014-9485](https://cve.mitre.org/cgi-bin/cvename.cgi?name=2014-9485)\n\n### Getting Started\n\nIn order to use and compile zipper you need to have [zlib](http://www.zlib.net) source files.\n**Zipper** depends on minizip as well but since it is used as a submodule, you get it when cloning\nthe repo and it gets compiled with the project.\n\n*Note*: For windows users, zlib is expected to be found at ZLIBROOT. Soon Zipper\nwill follow the new generation of zlib named [zlib-ng](https://github.com/zlib-ng/zlib-ng) and will be\ncompiled directly with this project.\n\n#### Download dependencies\n\n```shell\nsudo apt-get install zlib1g-dev  # for ubuntu\n\nsudo dnf install zlib-devel  # for fedora\nsudo dnf install gcc-c++  # for fedora\n```\n\n#### Compiling\n\nThe preferred way is to create a folder for the compilation output to avoid polluting the root folder\n\n```shell\ngit clone --recursive https://github.com/sebastiandev/zipper.git  # to get zipper and minizip submodule\ncd zipper\nmkdir build\ncd build\ncmake ../\nmake\n```\n\n#### Installing\n\nFollowing the previous section `Compiling`, still from the `build` folder, type:\n\n```shell\nsudo make install\nsudo ldconfig\n```\n\nYou will see a message like:\n\n```shell\nInstall the project...\n-- Install configuration: \"Release\"\n-- Installing: /usr/local/lib/libZipper.so.1.0.1\n-- Up-to-date: /usr/local/lib/libZipper.so.1\n-- Up-to-date: /usr/local/lib/libZipper.so\n-- Installing: /usr/local/lib/libZipper.a\n-- Installing: /usr/local/lib/libZipper-static.a\n-- Installing: /usr/local/bin/Zipper-test\n-- Installing: /usr/local/share/pkgconfig/zipper.pc\n-- Installing: /usr/local/bin/Zipper-test\n-- Installing: /usr/local/include/zipper/crypt.h\n-- Installing: /usr/local/include/zipper/ioapi.h\n-- Installing: /usr/local/include/zipper/ioapi_buf.h\n-- Installing: /usr/local/include/zipper/ioapi_mem.h\n-- Installing: /usr/local/include/zipper/iowin32.h\n-- Installing: /usr/local/include/zipper/unzip.h\n-- Installing: /usr/local/include/zipper/zip.h\n-- Installing: /usr/local/include/zipper/CDirEntry.h\n-- Installing: /usr/local/include/zipper/defs.h\n-- Installing: /usr/local/include/zipper/tools.h\n-- Installing: /usr/local/include/zipper/unzipper.h\n-- Installing: /usr/local/include/zipper/zipper.h\n-- Installing: /usr/local/lib/cmake/zipperConfig.cmake\n-- Installing: /usr/local/lib/cmake/zipperTargets.cmake\n-- Installing: /usr/local/lib/cmake/zipperTargets-release.cmake\n```\n\n### Usage\n\nThere are two classes available Zipper and Unzipper. They behave in the same manner regarding constructors and storage parameters. (for a complete example take a look at the [zip file tests](test/file_zip_test.cpp) and [zip memory tests](test/memory_zip_test.cpp) using the awesome BDD's from Catch library )\n\n#### Zipping\n\n:warning: **This project and particularly this master branch is no longer maintained. The new repo is:**\nhttps://github.com/Lecrapouille/zipper based on https://github.com/sebastiandev/zipper/tree/v2.x.y\n- Header:\n\n```c++\n#include \u003czipper/zipper.h\u003e\nusing namespace zipper;\n```\n\n- Creating a zip file with 2 files:\n\n```c++\nstd::ifstream input1(\"some file\");\nstd::ifstream input2(\"some file\");\n\nZipper zipper(\"ziptest.zip\");\nzipper.add(input1, \"Test1\");\nzipper.add(input2, \"Test1\");\n\nzipper.close();\n```\n\n- Adding a file by name and an entire folder to a zip:\n\n```c++\nZipper zipper(\"ziptest.zip\");\nzipper.add(\"somefile.txt\");\nzipper.add(\"myFolder\");\nzipper.close();\n```\n\n- Creating a zip file using the awesome streams from boost that lets us use a vector as a stream:\n\n```c++\n#include \u003cboost\\interprocess\\streams\\vectorstream.hpp\u003e\n...\n\nboost::interprocess::basic_vectorstream\u003cstd::vector\u003cchar\u003e\u003e input_data(some_vector);\n\nZipper zipper(\"ziptest.zip\");\nzipper.add(input_data, \"Test1\");\nzipper.close();\n```\n\n- Creating a zip in memory stream with files:\n\n```c++\n#include \u003cboost\\interprocess\\streams\\vectorstream.hpp\u003e\n...\n\nboost::interprocess::basic_vectorstream\u003cstd::vector\u003cchar\u003e\u003e zip_in_memory;\nstd::ifstream input1(\"some file\");\n\nZipper zipper(zip_in_memory);\nzipper.add(input1, \"Test1\");\nzipper.close();\n```\n\n- Creating a zip in a vector with files:\n\n```c++\nstd::vector\u003cunsigned char\u003e zip_vect;\nstd::ifstream input1(\"some file\");\n\nZipper zipper(zip_vect);\nzipper.add(input1, \"Test1\");\nzipper.close();\n```\n\n- Changing the compression factor: By default the `add` method uses an implicit flag `Zipper::Better`\nwhich compress the best but can takes some time to perform the compression. You can change this flag by `Zipper::Store` (no compression) or `Zipper::Faster` (for a light compression) or `Zipper::Medium` (for a compromise).\n\n```c++\nzipper.add(input1, \"Test1\", Zipper::Medium);\n```\n\n- Adding a password. You can protect your file by adding a password as a `std::string` as second parameter to any of `Zipper` constructors. For example:\n\n```c++\nZipper zipper(\"ziptest.zip\", \"mypassword\");\n```\n\n- Appending files inside the archive.\n\nBy default the constructor `Zipper` for zip file uses an implicit flag `Zipper::Overwrite` you can\nchange it by `Zipper::Append`. Note: in previous versions of Zipper the `Zipper::Append` flag was the one by default but now replaced by `Zipper::Overwrite`.\n\n##### Unzipping\n\n:warning: **This project and particularly this master branch is no longer maintained. The new repo is:**\nhttps://github.com/Lecrapouille/zipper based on https://github.com/sebastiandev/zipper/tree/v2.x.y\n\n- Header:\n\n```c++\n#include \u003czipper/unzipper.h\u003e\nusing namespace zipper;\n```\n\n- Getting all entries in zip:\n\n```c++\nUnzipper unzipper(\"zipfile.zip\");\nstd::vector\u003cZipEntry\u003e entries = unzipper.entries();\nunzipper.close();\n```\n\n- Extracting all entries from zip:\n\n```c++\nUnzipper unzipper(\"zipfile.zip\");\nunzipper.extract();\nunzipper.close();\n```\n\n- Extracting all entries from zip using alternative names for existing files on disk:\n\n```c++\nstd::map\u003cstd::string, std::string\u003e alternativeNames = { {\"Test1\", \"alternative_name_test1\"} };\nUnzipper unzipper(\"zipfile.zip\");\nunzipper.extract(\".\", alternativeNames);\nunzipper.close();\n```\n\n- Extracting a single entry from zip:\n\n```c++\nUnzipper unzipper(\"zipfile.zip\");\nunzipper.extractEntry(\"entry name\");\nunzipper.close();\n```\n\n- Extracting a single entry from zip to memory:\n\n```c++\nstd::vector\u003cunsigned char\u003e unzipped_entry;\nUnzipper unzipper(\"zipfile.zip\");\nunzipper.extractEntryToMemory(\"entry name\", unzipped_entry);\nunzipper.close();\n```\n\n- Extracting from a vector:\n\n```c++\n\nstd::vector\u003cunsigned char\u003e zip_vect; // Populated with Zipper zipper(zip_vect);\n\nUnzipper unzipper(zip_vect);\nunzipper.extractEntry(\"Test1\")\n```\n\n**Note:** Methods `extract`, `extractEntry`, `extractEntryToMemory` return a boolean indicating the success (`true`) or the failure (`false`).\n\n- Extraction using a password. You can pass your password as a `std::string` as second parameter to any of constructors:\n\n```c++\nZipper unzipper(\"ziptest.zip\", \"mypassword\");\n```\n\n##### Linking Zipper to your project\n\nIn your project add the needed headers in your c++ files:\n\n```c++\n#include \u003czipper/unzipper.h\u003e\n#include \u003czipper/zipper.h\u003e\n```\n\nThere are several ways to link your project against Zipper:\n\n- Straight forward: `g++ -W -Wall -I/usr/local/include main.cpp -o prog -L/usr/local/lib/ -lZipper -lz`. Note: you may have to adapt `/usr/local` to your installation directory (see the previous section `Installing`). You can also adapt and export your environment variable `LD_LIBRARY_PATH` (via you .bashrc for example).\n\n- Pkg-config is a better alternative to the previous command:\n\n```shell\ng++ -W -Wall main.cpp -o prog `pkg-config zipper --cflags --libs`\n```\n\nIndeed pkg-config knows for you where to find libraries and, by default, it will choose the shared library. In the case it is not present then the static library will be chosen. You can force choosing the static library with `pkg-config libZipper --static --libs`\n\n- Makefile: set `LDFLAGS` to `pkg-config zipper --libs` and set `CPPFLAGS` to `pkg-config zipper --cflags`\n\n- CMake:  Simply place zipper in your project hierarchy, and then use `add_subdirectory(zipper)` or whatever you called the zipper folder. Then link it with `Zipper`/`staticZipper`\n\n```cmake\nProject(projZipper)\n\nadd_subdirectory(zipper)\n\nadd_executable(projZipper main.cpp)\ntarget_link_libraries(\n    projZipper\n    PUBLIC\n    staticZipper\n)\n```\n\nlink zipper librairy(.so) to your own project with cmake\n```\nproject(projZipper)\n\nfind_package(PkgConfig REQUIRED)\npkg_check_modules(ZIPPER REQUIRED zipper)\n\nadd_executable(projZipper main.cpp)\n\ntarget_link_libraries(projZipper ${ZIPPER_LIBRARIES})\n```\n\n\n### For developpers\n\n##### Git branches\n\n- The `developement` is here for your pull requests. This branch contains the latest fixes but can have regressions.\n- The `master` is for maintenaning the stablest version.\n\nBecause, Zipper uses submodules, when your are commuting of branch, do not forget to synchronize your submodules:\n\n``` shell\ngit submodule sync\ngit submodule update\n```\n\n##### Coding style\n\nBefore submitting a pull request, you can indent the code with the following command:\n\n```shell\ncd zipper\nclang-format -i *.cpp *.h\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastiandev%2Fzipper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebastiandev%2Fzipper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastiandev%2Fzipper/lists"}