StormLib API Reference

SFileFlushArchive

Description

bool WINAPI SFileFlushArchive(
  HANDLE hMpq                       // Handle to an open MPQ
);

Function SFileFlushArchive saves any in-memory structures to the MPQ archive on disk. Due to performance reasons, StormLib caches several data structures in memory (e.g. block table or hash table). When a file is added to the MPQ, those structures are only updated in memory. Calling SFileFlushArchive forces saving in-memory MPQ tables to the file, preventing a MPQ corruption incase of power down or crash of the calling application.

Note that this function is called internally when the archive is closed.

Parameters

hMpq
[in] Handle to an open MPQ.

Return Value

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

Remarks

If the archive changed since it's been open, this function saves (listfile), (attributes) and MPQ tables. If any of those steps fail, the function tries to save as much as possible, and returns false. There are several conditions when this function may fail:

In the latter case, the archive will most likely be corrupt. The calling application must ensure that there is enough free disk space when modifying MPQ archives.

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