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