Pack v2.0.4
writer.h File Reference

Pack file writer. More...

#include "pack/common.h"

Typedefs

typedef void(* OnPackFile) (uint64_t itemIndex, void *argument)
 File packing callback.
 

Functions

PackResult packFiles (const char *packPath, uint64_t fileCount, const char **fileItemPaths, float zipThreshold, bool printProgress, OnPackFile onPackFile, void *argument)
 Packs files to the Pack archive.
 

Detailed Description

Pack file writer.

Used to pack files into a Pack archives. During packing, files are compressed with maximum ZSTD compression, or written as they are if they are already compressed. Additionally, each file is checked for data duplication, and in cases where two files are identical, a reference to the data of the already packed file is written.

Typedef Documentation

◆ OnPackFile

typedef void(* OnPackFile) (uint64_t itemIndex, void *argument)

File packing callback.

Parameters
itemIndexcurrent packing item index
argumentcallback agument, or NULL

Function Documentation

◆ packFiles()

PackResult packFiles ( const char * packPath,
uint64_t fileCount,
const char ** fileItemPaths,
float zipThreshold,
bool printProgress,
OnPackFile onPackFile,
void * argument )

Packs files to the Pack archive.

The main function for packing a Pack archives. It reads the provided files and compresses them with maximum possible compression. You can speed up the runtime file decompression by specifying a zipThreshold value, as if after compression, we achieve only 10% compression, then decompression will consume more resources than we save on file size. The optimal float value for the zipThreshold is 0.1f.

Parameters
[in]packPathoutput Pack file path string
fileCountfile count to pack
[in]fileItemPathspack file and item path string array (file/item, file/item...)
zipThresholdcompression threshold (0.0 - 1.0 range)
printProgressoutput packing progress to the stdout
[in]onPackFilefile packing callback, or NULL
[in]argumentfile packing callback argument, or NULL
Returns
The PackResult code.