| 206 | } |
| 207 | |
| 208 | static bool DoMPQSearch_FileEntry( |
| 209 | TMPQSearch * hs, |
| 210 | SFILE_FIND_DATA * lpFindFileData, |
| 211 | TMPQArchive * ha, |
| 212 | TMPQHash * pHashEntry, |
| 213 | TFileEntry * pFileEntry) |
| 214 | { |
| 215 | TFileEntry * pPatchEntry; |
| 216 | HANDLE hFile = NULL; |
| 217 | const char * szFileName; |
| 218 | size_t nPrefixLength = (ha->pPatchPrefix != NULL) ? ha->pPatchPrefix->nLength : 0; |
| 219 | DWORD dwBlockIndex; |
| 220 | char szNameBuff[MAX_PATH]; |
| 221 | |
| 222 | // Is it a file but not a patch file? |
| 223 | if((pFileEntry->dwFlags & hs->dwFlagMask) == MPQ_FILE_EXISTS) |
| 224 | { |
| 225 | // Now we have to check if this file was not enumerated before |
| 226 | if(!FileWasFoundBefore(ha, hs, pFileEntry)) |
| 227 | { |
| 228 | // if(pFileEntry != NULL && !_stricmp(pFileEntry->szFileName, "TriggerLibs\\NativeLib.galaxy")) |
| 229 | // DebugBreak(); |
| 230 | |
| 231 | // Find a patch to this file |
| 232 | // Note: This either succeeds or returns pFileEntry |
| 233 | pPatchEntry = FindPatchEntry(ha, pFileEntry); |
| 234 | |
| 235 | // Prepare the block index |
| 236 | dwBlockIndex = (DWORD)(pFileEntry - ha->pFileTable); |
| 237 | |
| 238 | // Get the file name. If it's not known, we will create pseudo-name |
| 239 | szFileName = pFileEntry->szFileName; |
| 240 | if(szFileName == NULL) |
| 241 | { |
| 242 | // Open the file by its pseudo-name. |
| 243 | sprintf(szNameBuff, "File%08u.xxx", (unsigned int)dwBlockIndex); |
| 244 | if(SFileOpenFileEx((HANDLE)hs->ha, szNameBuff, SFILE_OPEN_BASE_FILE, &hFile)) |
| 245 | { |
| 246 | SFileGetFileName(hFile, szNameBuff); |
| 247 | szFileName = szNameBuff; |
| 248 | SFileCloseFile(hFile); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | // If the file name is still NULL, we cannot include the file to search results |
| 253 | if(szFileName != NULL) |
| 254 | { |
| 255 | // Check the file name against the wildcard |
| 256 | if(CheckWildCard(szFileName + nPrefixLength, hs->szSearchMask)) |
| 257 | { |
| 258 | // Fill the found entry. hash entry and block index are taken from the base MPQ |
| 259 | lpFindFileData->dwHashIndex = HASH_ENTRY_FREE; |
| 260 | lpFindFileData->dwBlockIndex = dwBlockIndex; |
| 261 | lpFindFileData->dwFileSize = pPatchEntry->dwFileSize; |
| 262 | lpFindFileData->dwFileFlags = pPatchEntry->dwFlags; |
| 263 | lpFindFileData->dwCompSize = pPatchEntry->dwCmpSize; |
| 264 | lpFindFileData->lcLocale = 0; // pPatchEntry->lcLocale; |
| 265 |
no test coverage detected