StormLib API Reference

SFileCompactArchive

Description

bool WINAPI SFileCompactArchive(
  HANDLE hMpq,                      // Handle to an open MPQ
  const char * szListFile           // Name of an extra listfile
  bool bReserved                    // Reserved, not used
);

Performs a complete archive rebuild, effectively defragmenting the MPQ archive, removing all gaps that have been created by adding, replacing, renaming or deleting files within the archive. To succeed, the function requires all files in MPQ archive to be accessible. See Remarks section for more information.

SFileCompactArchive might take several minutes to complete, depending on size of the archive being rebuilt. If you want to use SFileCompactArchive in your application, you can utilize a compact callback, which can be set by SFileSetCompactCallback.

Parameters

hMpq
[in] Handle to an open MPQ. The MPQ must have been open by SFileOpenArchive or created by SFileCreateArchive.
szListFile
[in] Allows to specify an additional listfile, that will be used together with internal listfile. Can be NULL.
bReserved
[in] Not used, set to zero.

Return Value

When the function succeeds, it returns nonzero. On an error, the function returns false and GetLastError gives the error code.

Remarks

It is necessary that at the moment of calling SFileCompactArchive, all files must be accessible. This means, that either name of each file in the MPQ must be known, or the file in MPQ must not be encrypted. During initialization phase, SFileCompactArchive checks if the compacting can be done and returns an error code if otherwise. Callers of SFileCompactArchive are recommended to provide a full listfile for the compacted archive.

Availability in Storm.dll

Available in Storm.dll No
Ordinal number in Storm.dll 1.00 N/A
Ordinal number in Storm.dll 1.09 N/A