The c++ interface to operate ZIP files. No libraries required. Just one header and one c file.
It is based on miniz - https://code.google.com/archive/p/miniz/ (completely free)
Just add miniz.c and zpp.h into your project. Include zpp.h and use the classes defined there. No any library required!
Look the zipFileWriter and zipFileReader, the interfaces are self-obvious. Examples of usage
- Create zip from the folder
zipFileWriter z("output_path.zip");
z.addFolder("./folder_to_zip/");
z.flush();
- Add single file to ZIP
zipFileWriter z("output_path.zip");
z.addFile("./some_path/filename.txt", "path_in_archive.txt");
z.flush();
- Add string/raw data as the record in the ZIP file.
zipFileWriter z("output_path.zip");
z.addString("The text to be ziped", "path_in_archive.txt");
z.flush();
- Extract the whole archive
zipFileReader r("path_to_archive.zip");
r.extractAll("./output_path/");
- Extract single file (the first one in the ZIP). It is helpful if the ZIP contains just one file.
zipFileReader r("path_to_archive.zip");
r.extractFirstToFile("destination_path_for_single_file.txt");
- List all files, extract only required files
zipFileReader r("path_to_archive.zip");
auto list = r.getFilesList();
for (auto e = list.begin(); e != list.end(); e++) {
std::cout << e->c_str() << "\n";
std::filesystem::path p = "./extract_path/";
p.append(e->c_str());
r.extractToFile(e->c_str(), p.generic_u8string());
}
Completely free. Look https://code.google.com/archive/p/miniz/