StormLib API Reference

SFileWriteFile

Description

bool WINAPI SFileWriteFile(
  HANDLE hFile,                     // Handle to the file
  const void * pvData,              // Pointer to data to be written
  DWORD dwSize,                     // Size of the data pointed by pvData
  DWORD dwCompression               // Specifies compression of the data block
);

Function SFileWriteFile writes data to the archive. The file must have been created by SFileCreateFile.

Parameters

hFile
[in] Handle to a new file within MPQ. This handle must have been obtained by calling SFileCreateFile.
pvData
[in] Pointer to data to be written to the file.
dwSize
[in] Size of the data that are to be written to the MPQ.
dwCompression
[in] Specifies the type of data compression that is to be applied to the data, in case the amount of the data will reach size of one file sector. For more information about the available compressions, see SFileAddFileEx.

Return Value

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

Remarks

The amount of data written by one call of SFileWriteFile may be arbitrary. Attempt to write zero data equals to no operation and succeeds. SFileWriteFile collects the data into a memory buffer, up to the size of one file sector. After that, the data is compressed (if wanted), encrypted (if wanted) and flushed to the MPQ.

The caller must make sure that the total amount of data written to the file will exactly match to the file size, specified by call to SFileCreateFile. Attempting to write more data causes the function to return false and GetLastError() returns ERROR_DISK_FULL.

The dwCompression only applies when amount of buffered data stored by SFileWriteFile reaches size of one file sector, and thus the data will be written to the MPQ. Otherwise, it has no effect.

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