CRC32 crc = new CRC32();
long stillToRead = dir.size;
raf.seek(dir.offset);
int length = (int) Math.min(BUFFER_SIZE, stillToRead);
byte[] buffer = new byte[BUFFER_SIZE];
length = raf.read(buffer, 0, length);
while (length != -1) {
crc.update(buffer, 0, length);
stillToRead -= length;
if (stillToRead == 0) {
break;
}
length = (int) Math.min(BUFFER_SIZE, stillToRead);
length = raf.read(buffer, 0, length);
}
return crc.getValue();