| 1265 | } |
| 1266 | |
| 1267 | static int InsertHetEntry(TMPQHetTable * pHetTable, ULONGLONG FileNameHash, DWORD dwFileIndex) |
| 1268 | { |
| 1269 | DWORD StartIndex; |
| 1270 | DWORD Index; |
| 1271 | BYTE NameHash1; |
| 1272 | |
| 1273 | // Get the start index and the high 8 bits of the name hash |
| 1274 | StartIndex = Index = (DWORD)(FileNameHash % pHetTable->dwTotalCount); |
| 1275 | NameHash1 = (BYTE)(FileNameHash >> (pHetTable->dwNameHashBitSize - 8)); |
| 1276 | |
| 1277 | // Find a place where to put it |
| 1278 | for(;;) |
| 1279 | { |
| 1280 | // Did we find a free HET entry? |
| 1281 | if(pHetTable->pNameHashes[Index] == HET_ENTRY_FREE) |
| 1282 | { |
| 1283 | // Set the entry in the name hash table |
| 1284 | pHetTable->pNameHashes[Index] = NameHash1; |
| 1285 | |
| 1286 | // Set the entry in the file index table |
| 1287 | SetBits(pHetTable->pBetIndexes, pHetTable->dwIndexSizeTotal * Index, |
| 1288 | pHetTable->dwIndexSize, |
| 1289 | &dwFileIndex, |
| 1290 | 4); |
| 1291 | return ERROR_SUCCESS; |
| 1292 | } |
| 1293 | |
| 1294 | // Move to the next entry in the HET table |
| 1295 | // If we came to the start index again, we are done |
| 1296 | Index = (Index + 1) % pHetTable->dwTotalCount; |
| 1297 | if(Index == StartIndex) |
| 1298 | break; |
| 1299 | } |
| 1300 | |
| 1301 | // No space in the HET table. Should never happen, |
| 1302 | // because the HET table is created according to the number of files |
| 1303 | assert(false); |
| 1304 | return ERROR_DISK_FULL; |
| 1305 | } |
| 1306 | |
| 1307 | static TMPQHetTable * TranslateHetTable(TMPQHetHeader * pHetHeader) |
| 1308 | { |
no test coverage detected