MCPcopy Create free account
hub / github.com/Kenix3/libultraship / SFileWriteFile

Function SFileWriteFile

extern/StormLib/src/SFileAddFile.cpp:818–862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

816}
817
818bool WINAPI SFileWriteFile(
819 HANDLE hFile,
820 const void * pvData,
821 DWORD dwSize,
822 DWORD dwCompression)
823{
824 TMPQFile * hf = (TMPQFile *)hFile;
825 DWORD dwErrCode = ERROR_SUCCESS;
826
827 // Check the proper parameters
828 if(!IsValidFileHandle(hFile))
829 dwErrCode = ERROR_INVALID_HANDLE;
830 if(hf->bIsWriteHandle == false)
831 dwErrCode = ERROR_INVALID_HANDLE;
832
833 // Special checks for single unit files
834 if(dwErrCode == ERROR_SUCCESS && (hf->pFileEntry->dwFlags & MPQ_FILE_SINGLE_UNIT))
835 {
836 //
837 // Note: Blizzard doesn't support single unit files
838 // that are stored as encrypted or imploded. We will allow them here,
839 // the calling application must ensure that such flag combination doesn't get here
840 //
841
842// if(dwFlags & MPQ_FILE_IMPLODE)
843// dwErrCode = ERROR_INVALID_PARAMETER;
844//
845// if(dwFlags & MPQ_FILE_ENCRYPTED)
846// dwErrCode = ERROR_INVALID_PARAMETER;
847
848 // Lossy compression is not allowed on single unit files
849 if(dwCompression & MPQ_LOSSY_COMPRESSION_MASK)
850 dwErrCode = ERROR_INVALID_PARAMETER;
851 }
852
853
854 // Write the data to the file
855 if(dwErrCode == ERROR_SUCCESS)
856 dwErrCode = SFileAddFile_Write(hf, pvData, dwSize, dwCompression);
857
858 // Deal with errors
859 if(dwErrCode != ERROR_SUCCESS)
860 SetLastError(dwErrCode);
861 return (dwErrCode == ERROR_SUCCESS);
862}
863
864bool WINAPI SFileFinishFile(HANDLE hFile)
865{

Callers 3

AddFileToMpqFunction · 0.85
SFileAddFileExFunction · 0.85
AddFileMethod · 0.85

Calls 3

IsValidFileHandleFunction · 0.85
SFileAddFile_WriteFunction · 0.85
SetLastErrorFunction · 0.85

Tested by 1

AddFileToMpqFunction · 0.68