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

Function SFileAddFile_Finish

extern/StormLib/src/SFileAddFile.cpp:711–757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

709}
710
711DWORD SFileAddFile_Finish(TMPQFile * hf)
712{
713 TMPQArchive * ha = hf->ha;
714 TFileEntry * pFileEntry = hf->pFileEntry;
715 DWORD dwErrCode = hf->dwAddFileError;
716
717 // If all previous operations succeeded, we can update the MPQ
718 if(dwErrCode == ERROR_SUCCESS)
719 {
720 // Verify if the caller wrote the file properly
721 if(hf->pPatchInfo == NULL)
722 {
723 assert(pFileEntry != NULL);
724 if(hf->dwFilePos != pFileEntry->dwFileSize)
725 dwErrCode = ERROR_CAN_NOT_COMPLETE;
726 }
727 else
728 {
729 if(hf->dwFilePos != hf->pPatchInfo->dwDataSize)
730 dwErrCode = ERROR_CAN_NOT_COMPLETE;
731 }
732 }
733
734 // Now we need to recreate the HET table, if exists
735 if(dwErrCode == ERROR_SUCCESS && ha->pHetTable != NULL)
736 {
737 dwErrCode = RebuildHetTable(ha);
738 }
739
740 // Update the block table size
741 if(dwErrCode == ERROR_SUCCESS)
742 {
743 // Call the user callback, if any
744 if(ha->pfnAddFileCB != NULL)
745 ha->pfnAddFileCB(ha->pvAddFileUserData, hf->dwDataSize, hf->dwDataSize, true);
746 }
747 else
748 {
749 // Free the file entry in MPQ tables
750 if(pFileEntry != NULL)
751 DeleteFileEntry(ha, hf);
752 }
753
754 // Clear the add file callback
755 FreeFileHandle(hf);
756 return dwErrCode;
757}
758
759//-----------------------------------------------------------------------------
760// Adds data as file to the archive

Callers 4

SSignFileCreateFunction · 0.85
SFileFinishFileFunction · 0.85
SListFileSaveToMpqFunction · 0.85
SAttrFileSaveToMpqFunction · 0.85

Calls 3

RebuildHetTableFunction · 0.85
DeleteFileEntryFunction · 0.85
FreeFileHandleFunction · 0.85

Tested by

no test coverage detected