Fixed a bug that would cause things to go south if you added files in

a certain pattern.  The problem was an uninitialized "fakeThreads".

Added some comments and tweaked an error message while I was at it.
This commit is contained in:
Andy McFadden 2003-03-11 22:11:22 +00:00
parent fa2bd0b91b
commit ada1d8de04
3 changed files with 12 additions and 2 deletions

View File

@ -1232,8 +1232,8 @@ Nu_CopyFileSection(NuArchive* pArchive, FILE* dstFp, FILE* srcFp, long length)
if (err != kNuErrNone) { if (err != kNuErrNone) {
Nu_ReportError(NU_BLOB, err, Nu_ReportError(NU_BLOB, err,
"Nu_FRead failed while copying file section " "Nu_FRead failed while copying file section "
"(fp=0x%08lx, readLen=%ld, err=%d)\n", "(fp=0x%08lx, readLen=%ld, length=%ld, err=%d)\n",
(long) srcFp, readLen, err); (long) srcFp, readLen, length, err);
goto bail; goto bail;
} }
err = Nu_FWrite(dstFp, pArchive->compBuf, readLen); err = Nu_FWrite(dstFp, pArchive->compBuf, readLen);

View File

@ -412,6 +412,8 @@ typedef struct NuThread {
/* /*
* NuFX "record" definition. * NuFX "record" definition.
*
* (Note to developers: update Nu_AddRecord if this changes.)
*/ */
#define kNufxIDLen 4 /* len of 'NuFX' with funky MSBs */ #define kNufxIDLen 4 /* len of 'NuFX' with funky MSBs */
#define kNuReasonableAttribCount 256 #define kNuReasonableAttribCount 256

View File

@ -1265,6 +1265,11 @@ Nu_WriteRecordHeader(NuArchive* pArchive, NuRecord* pRecord, FILE* fp)
/* /*
* Update values for misc record fields. * Update values for misc record fields.
*
* Note that, despite having written the record header, we can still
* have "fake" threads. This is because WriteThreadHeaders only saves
* the real ones. This is in line with our policy of not altering
* anything we don't have to.
*/ */
pRecord->recHeaderLength = pRecord->recHeaderLength =
bytesWritten + pRecord->recTotalThreads * kNuThreadHeaderSize; bytesWritten + pRecord->recTotalThreads * kNuThreadHeaderSize;
@ -2295,9 +2300,12 @@ Nu_AddRecord(NuArchive* pArchive, const NuFileDetails* pFileDetails,
pNewRecord->recFilenameLength = 0; pNewRecord->recFilenameLength = 0;
pNewRecord->recordIdx = Nu_GetNextRecordIdx(pArchive); pNewRecord->recordIdx = Nu_GetNextRecordIdx(pArchive);
pNewRecord->threadFilename = nil;
pNewRecord->newFilename = strdup(pFileDetails->storageName); pNewRecord->newFilename = strdup(pFileDetails->storageName);
pNewRecord->filename = pNewRecord->newFilename; pNewRecord->filename = pNewRecord->newFilename;
pNewRecord->recHeaderLength = -1;
pNewRecord->totalCompLength = 0; pNewRecord->totalCompLength = 0;
pNewRecord->fakeThreads = 0;
pNewRecord->fileOffset = -1; pNewRecord->fileOffset = -1;
/* /*