MCPcopy Create free account
hub / github.com/diasurgical/devilution / InvalidateInternalFile

Function InvalidateInternalFile

3rdParty/StormLib/src/SBaseFileTable.cpp:2075–2102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2073}
2074
2075DWORD InvalidateInternalFile(TMPQArchive * ha, const char * szFileName, DWORD dwFlagNone, DWORD dwFlagNew)
2076{
2077 TMPQFile * hf = NULL;
2078 DWORD dwFileFlags = 0;
2079 int nError = ERROR_FILE_NOT_FOUND;
2080
2081 // Open the file from the MPQ
2082 if(SFileOpenFileEx((HANDLE)ha, szFileName, SFILE_OPEN_BASE_FILE, (HANDLE *)&hf))
2083 {
2084 // Remember the file flags
2085 dwFileFlags = hf->pFileEntry->dwFlags;
2086
2087 // Delete the file entry
2088 nError = DeleteFileEntry(ha, hf);
2089 if(nError == ERROR_SUCCESS)
2090 {
2091 ha->dwFlags |= dwFlagNew;
2092 ha->dwReservedFiles++;
2093 }
2094
2095 // Free the file entry
2096 FreeFileHandle(hf);
2097 }
2098
2099 // If the deletion failed, set the "none" flag
2100 ha->dwFlags |= (nError != ERROR_SUCCESS) ? dwFlagNone : 0;
2101 return dwFileFlags;
2102}
2103
2104void InvalidateInternalFiles(TMPQArchive * ha)
2105{

Callers 1

InvalidateInternalFilesFunction · 0.85

Calls 3

SFileOpenFileExFunction · 0.85
DeleteFileEntryFunction · 0.85
FreeFileHandleFunction · 0.85

Tested by

no test coverage detected