Is there something like a class that might be used to store Files and directories in, just like the way Zip files might be used?
Since I haven't found any "real" class to write Zip files (real class as in real class), It would be nice to be able to store Files and Directories in a container-like file.
A perfect API would probably look like this:
int main()
{
ContainerFile cntf("myContainer.cnt", ContainerFile::CREATE);
cntf.addFile("data/some-interesting-stuff.txt");
cntf.addDirectory("data/foo/");
cntf.addDirectory("data/bar/", ContainerFile::RECURSIVE);
cntf.close();
}
... I hope you get the Idea. Important Requirements are:
I already played with the thought of creating an Implentation based on SQLite (and its ability to store binary blobs). Unfortunately, it seems impossible to store Directory structures in a SQLite Database, which makes it pretty much useless in this case.
Is it useless to hope for such a class library?
I took the time to write a tiny, yet working wrapper around libarchive. I'm not exactly familiar with all features of Libarchive, but the result fits what I needed:
archive_wrapper.cpp @ gist.github.com
It uses libmars for strings, etc. But I guess it wouldn't be too hard to replace the mars::mstring
occurances with std::string
.
And of course this wrapper is available under the MIT/X11 License (just as libmars), which means you can do whatever you want with it. ;-)