libgamearchive provides a standard interface to access different game data "archives" regardless of their file format. Just like a .zip file, many games squash all their data files together into one big file, and this library provides access to those single big files. Files can be listed and extracted, as well as added, removed, renamed and rearranged.


The main interface to the library is the getManager() function, which returns an instance of the Manager class. The Manager is used to query supported archive formats, and for each supported file format it returns an instance of the ArchiveType class.

The ArchiveType class can be used to examine files and check what file format they are in, and if they are in the correct format, to open them. Successfully opening an archive file produces an instance of the Archive class. The ArchiveType class can also be used to create new archives from scratch, which will again return an Archive instance.

The Archive class is used to directly manipulate the archive file, such as by adding and removing files.


The libgamearchive distribution comes with example code in the form of the gamearch utility, which provides a simple command-line interface to the full functionality of the library.

For a small "hello world" example, try this:

#include <iostream>
using namespace camoto;
using namespace camoto::gamearchive;
int main(void)
// Get hold of the Manager class
ManagerPtr manager = getManager();
// Use the manager to look up a particular archive format
ArchiveTypePtr archiveType = manager->getArchiveTypeByCode("grp-duke3d");
// Open an archive file on disk
// We cheat here - we should check and load any supplementary files, but
// for the sake of keeping this example simple we know this format doesn't
// need any supps.
// Use the archive format handler to read in the file we opened as an archive
ArchivePtr arch = archiveType->open(file, supps);
// Get a list of all the files in the archive
const Archive::VC_ENTRYPTR& contents = arch->getFileList();
// Print the size of the list (the number of files in the archive)
std::cout << "Found " << contents.size() << " files.\n";
// Run through the list of files and show the filename
for (Archive::VC_ENTRYPTR::const_iterator i = contents.begin(); i != contents.end(); i++) {
const Archive::EntryPtr subfile = *i;
std::cout << subfile->strName << "\n";
std::cout << "Done." << std::endl;
// No cleanup required because all the Ptr variables are shared pointers,
// which get destroyed automatically when they go out of scope (and nobody
// else is using them!)
return 0;

When run, this program produces output similar to the following:

Found 456 files.

More information

Additional information is available from the Camoto homepage