SZFILE Helper Library and Demo

Usage in Your Program

#include <cafe/szfile.h>

The SZFILE library is provided as a helper tool. It parses 7-Zip (.7z) files based on the publicly available information about the 7-Zip file format.

How it Works

Create a .7z file on Windows by installing the 7Zip toolkit from, and then using the tool directory or if you install the shell extension by right-clicking on selection of files or a folder and selecting 7ZipAdd To Archive or one of the other options on the menu.

The main library functions are SZFILE_CreateArc, SZFILE_Get, and SZFILE_PurgeArc.

The SZFILE_CreateArc function takes as input the address of a control structure to use, and a blob of memory that is the original .7z file, which has been placed into memory in its entirety by some mechanism (built in, loaded, etc). This library does not do the loading.

The library function uses allocate/free functions you provide to allocate and free memory as needed during operations with the archive. Different functions may be specified for different archives.

The manifest of directories in the archive contains the SZFILE_DIR and SZFILE_ENTRY structures that refer to each other. The structures are in target system byte order and can be used directly.

When you are finished with the archive you should purge all memory used for it using the SZFILE_PurgeArc function. This function does not remove or free the original blob of memory used to create the archive, which may not be freeable in some circumstances.

Demonstration of Use in Cafe

There is a demonstration of usage of the helper library in the demo folder:


Revision History

2012/01/30 Initial version.