This repo was originally found here (404), but @markand (BitBucket, GitHub, Website, Mercurial Server) has since taken the repo down for unknown reasons. The library had a permissive license, so I have re-uploaded/mirrored the library here for historical purposes.
In August 2020, the original library was found in a more updated version on the original author's Mercurial server here. I updated the code in this repo accordingly!
The libzip library is a good C library for opening and creating zip archives, this wrapper provides safe C++ classes around this great library.
The benefits:
- Automatic allocations and destructions (RAII),
- Easy way to add files,
- Easy API,
- Easy file reading in archive,
- Read only iterator interface,
- Convenience, thanks to C++ function overloads.
Just copy the file zippy.hpp and add it to your project.
A simple example of the extraction of a file.
#include <iostream>
#include "zip.hpp"
int main()
{
try {
libzip::archive archive("mydata.zip");
libzip::stat_info stat = archive.stat("README");
libzip::file file = archive.open("README");
std::cout << "content of README:" << std::endl;
std::cout << file.read(stat.size);
} catch (const std::exception &ex) {
std::cerr << ex.what() << std::endl;
}
}