SparseExtentHeader header = new SparseExtentHeader();
int magicNum = bb.getInt();
LOG.debug("magicNum=" + Long.toHexString(magicNum));
if (magicNum != MAGIC_NUMBER) {
throw new UnsupportedFormatException("not the magic number");
}
int version = bb.getInt();
if (version != VERSION) {
throw new IOException("bad version number (found:" + version + ")");
}
int flags = bb.getInt();
header.setValidNewLineDetectionTest((flags & 0x01) == 0x01); // bit 0
header.setRedundantGrainTableWillBeUsed((flags & 0x02) == 0x02); // bit
// 1
header.setCapacity(bb.getLong());
header.setGrainSize(bb.getLong());
header.setDescriptorOffset(bb.getLong());
header.setDescriptorSize(bb.getLong());
LOG.debug("read: offset(NumGTEsPerGT)=" + bb.position());
int nb = bb.getInt();
if (nb != numGTEsPerGT) {
throw new IOException("bad number of entries per grain table (found:" + nb + ")");
}
header.setNumGTEsPerGT(nb);
header.setRgdOffset(bb.getLong());
LOG.debug("read: offset(GdOffset)=" + bb.position());
header.setGdOffset(bb.getLong());
header.setOverHead(bb.getLong());
header.setUncleanShutdown(bb.get() == TRUE);
LOG.debug("read: offset(singleEndLineChar)=" + bb.position());
byte b = bb.get();
if (b != singleEndLineChar) {
throw new IOException("file corrupted after a FTP (singleEndLineChar=" + b + ")");
}
b = bb.get();
if (b != nonEndLineChar) {
throw new IOException("file corrupted after a FTP (nonEndLineChar=" + b + ")");
}
b = bb.get();
if (b != doubleEndLineChar1) {
throw new IOException("file corrupted after a FTP (doubleEndLineChar1=" + b + ")");
}
b = bb.get();
if (b != doubleEndLineChar2) {
throw new IOException("file corrupted after a FTP (doubleEndLineChar2=" + b + ")");
}
if (bb.remaining() < PAD_SIZE) {
throw new UnsupportedFormatException("bad pad size (size=" + bb.remaining() + ")");
}
// additional/computed attributes
IOUtils.computeGrainTableCoverage(header);