Fixed bits->bits translation so that it no longer errors out due to reading at the end of the stream
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5165 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1305,16 +1305,21 @@ translate_from_bits(BPositionIO *inSource, ssize_t amtread, uint8 *read,
|
|||||||
// write out the data (only if configured to)
|
// write out the data (only if configured to)
|
||||||
if (bdataonly || (!bheaderonly && !bdataonly)) {
|
if (bdataonly || (!bheaderonly && !bdataonly)) {
|
||||||
uint8 buf[1024];
|
uint8 buf[1024];
|
||||||
ssize_t rd = inSource->Read(buf, 1024);
|
uint32 remaining = B_BENDIAN_TO_HOST_INT32(bitsHeader.dataSize);
|
||||||
while (rd > 0) {
|
ssize_t rd, writ;
|
||||||
outDestination->Write(buf, rd);
|
|
||||||
rd = inSource->Read(buf, 1024);
|
rd = inSource->Read(buf, 1024);
|
||||||
|
while (rd > 0) {
|
||||||
|
writ = outDestination->Write(buf, rd);
|
||||||
|
if (writ < 0)
|
||||||
|
break;
|
||||||
|
remaining -= static_cast<uint32>(writ);
|
||||||
|
rd = inSource->Read(buf, min(1024, remaining));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rd == 0)
|
if (remaining > 0)
|
||||||
return B_OK;
|
|
||||||
else
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
else
|
||||||
|
return B_OK;
|
||||||
} else
|
} else
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user