mirror of
https://github.com/fadden/nulib2.git
synced 2024-07-02 23:29:37 +00:00
Better fix.
This commit is contained in:
parent
f265e2555a
commit
f1efb63d68
|
@ -440,8 +440,11 @@ BNYNormalizePath(BNYArchive* pBny, BNYEntry* pEntry)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy all data from the Binary II file to "outfp", reading in 128-byte
|
* Copy all data from the Binary II file to "outfp", reading in 128-byte
|
||||||
* blocks. Some programs (like ProTERM) apply a 128-byte header without
|
* blocks. We need to read multiples of 128 bytes so that we're ready to
|
||||||
* padding out the file length, so we do need to handle that here.
|
* read the next entry without additional seeking.
|
||||||
|
*
|
||||||
|
* Some programs (like ProTERM) apply a 128-byte header without padding
|
||||||
|
* out the file length, so we may come up short at the end of the file.
|
||||||
*
|
*
|
||||||
* Uses pEntry->blockBuf, which already has the first 128 bytes in it.
|
* Uses pEntry->blockBuf, which already has the first 128 bytes in it.
|
||||||
*/
|
*/
|
||||||
|
@ -472,11 +475,19 @@ BNYCopyBlocks(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp)
|
||||||
bytesLeft -= toWrite;
|
bytesLeft -= toWrite;
|
||||||
|
|
||||||
if (bytesLeft) {
|
if (bytesLeft) {
|
||||||
err = BNYRead(pBny, pEntry->blockBuf,
|
size_t actual;
|
||||||
bytesLeft < kBNYBlockSize ? bytesLeft : kBNYBlockSize);
|
|
||||||
if (err != kNuErrNone) {
|
errno = 0;
|
||||||
ReportError(err, "BNY read failed");
|
actual = fread(pEntry->blockBuf, 1, kBNYBlockSize, pBny->fp);
|
||||||
goto bail;
|
if (actual != kBNYBlockSize) {
|
||||||
|
/* failure or partial read */
|
||||||
|
if (actual != bytesLeft) {
|
||||||
|
err = errno ? errno : kNuErrFileRead;
|
||||||
|
ReportError(err, "BNY read failed");
|
||||||
|
goto bail;
|
||||||
|
} else {
|
||||||
|
DBUG(("+++ partial read %d/%d\n", actual, kBNYBlockSize));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -609,6 +620,7 @@ BNYUnSqueeze(BNYArchive* pBny, BNYEntry* pEntry, FILE* outfp)
|
||||||
|
|
||||||
usqState.dataInBuffer = 0;
|
usqState.dataInBuffer = 0;
|
||||||
usqState.dataPtr = tmpBuf;
|
usqState.dataPtr = tmpBuf;
|
||||||
|
usqState.bits = 0;
|
||||||
|
|
||||||
compRemaining = pEntry->realEOF;
|
compRemaining = pEntry->realEOF;
|
||||||
#ifdef FULL_SQ_HEADER
|
#ifdef FULL_SQ_HEADER
|
||||||
|
|
Loading…
Reference in New Issue
Block a user