Suppose I've defined
struct Data {
std::string fileName;
char* byteArray;
size_t size;
}
I want to be able to write something like the following:
std::vector<Data> vectorOfData;
// ... filling vectorOfData here ...
ZIP zipArchive; // from some library?
for (int i = 0; i < vectorOfData.size(); i++
{
const Data& d = vectorOfData[i];
zipArchive.insert(d.filename, d.byteArray, d.size);
}
std::string outputDestination = "/home/output.zip"
zipArchive.write(outputDestination);
Now, I know that's really, really simple. What I'm looking for is a library that has this functionality, and doesn't come with a massive amount of extra functionality that I'll get lost in, trying to figure out how it works.
My requirements are that the code has to be executed from within a C++ application (I can't write a script outside and call that, unfortunately!), and it needs to be cross-platform code, so I can compile on the 3 target platforms (Windows, OSX and Linux).
I have looked at zlib (which doesn't do zips), libzip (which doesn't have much in the way of examples, and has lots of extra functionality), and minizip (which has the same issue as libzip).
The reason I'm asking rather than trying to figure out the details of these large libraries is because I find it really surprising that a simple open-source solution doesn't exist. I'm more tempted to write one myself for my specific needs than rely on a large library that does too much, but I don't have time before the client needs the functionality :/