final int readThisTime = pis.read(allCRCBytes.array(), readAllCRCBytes, 4 - readAllCRCBytes);
if (readThisTime == -1) return false;
readAllCRCBytes += readThisTime;
}
final int allCRCExpected = allCRCBytes.getInt();
final CRC32 allCRC = new CRC32();
ByteBuffer entryBuffer = ByteBuffer.allocate(ENTRY_WITH_CHECKSUM_SIZE).order(ByteOrder.nativeOrder());
while (true) {
entryBuffer.clear();
int read = 0;
while (read < ENTRY_WITH_CHECKSUM_SIZE) {
final int readThisTime = pis.read(entryBuffer.array(), read, entryBuffer.capacity() - read);
if (readThisTime == -1) break;
read += readThisTime;
}
if (read == 0 || read < ENTRY_WITH_CHECKSUM_SIZE) {
final int actualAllCRC = (int)allCRC.getValue();
if (actualAllCRC != allCRCExpected) {
m_channel.close();
return false;
}
return true;
}
final int expectedCRC = entryBuffer.getInt();
final CRC32 crc = new CRC32();
crc.update(entryBuffer.array(), 4, entryBuffer.capacity() - 4);
final int actualCRC = (int)crc.getValue();
if (expectedCRC != actualCRC) {
m_channel.close();
return false;
}