| 1349 | } |
| 1350 | |
| 1351 | int WriteSectorOffsets(TMPQFile * hf) |
| 1352 | { |
| 1353 | TMPQArchive * ha = hf->ha; |
| 1354 | TFileEntry * pFileEntry = hf->pFileEntry; |
| 1355 | ULONGLONG RawFilePos = hf->RawFilePos; |
| 1356 | DWORD dwSectorOffsLen; |
| 1357 | |
| 1358 | // The caller must make sure that this function is only called |
| 1359 | // when the following is true. |
| 1360 | assert(hf->pFileEntry->dwFlags & MPQ_FILE_COMPRESS_MASK); |
| 1361 | assert(hf->SectorOffsets != NULL); |
| 1362 | dwSectorOffsLen = hf->SectorOffsets[0]; |
| 1363 | |
| 1364 | // If file is encrypted, sector positions are also encrypted |
| 1365 | if(pFileEntry->dwFlags & MPQ_FILE_ENCRYPTED) |
| 1366 | EncryptMpqBlock(hf->SectorOffsets, dwSectorOffsLen, hf->dwFileKey - 1); |
| 1367 | BSWAP_ARRAY32_UNSIGNED(hf->SectorOffsets, dwSectorOffsLen); |
| 1368 | |
| 1369 | // Adjust sector offset table position, if we also have patch info |
| 1370 | if(hf->pPatchInfo != NULL) |
| 1371 | RawFilePos += hf->pPatchInfo->dwLength; |
| 1372 | |
| 1373 | // Write sector offsets to the archive |
| 1374 | if(!FileStream_Write(ha->pStream, &RawFilePos, hf->SectorOffsets, dwSectorOffsLen)) |
| 1375 | return GetLastError(); |
| 1376 | |
| 1377 | // Not necessary, as the sector checksums |
| 1378 | // are going to be freed when this is done. |
| 1379 | // BSWAP_ARRAY32_UNSIGNED(hf->SectorOffsets, dwSectorOffsLen); |
| 1380 | return ERROR_SUCCESS; |
| 1381 | } |
| 1382 | |
| 1383 | |
| 1384 | int WriteSectorChecksums(TMPQFile * hf) |
nothing calls this directly
no test coverage detected