private /*P*/ byte[] readHeader(int id) throws IOException { /*P*/ byte[] header = p_alloc(MINIMUM_PAGE_SIZE); try { try { mPageArray.readPage(id, header, 0, MINIMUM_PAGE_SIZE); } catch (EOFException e) { throw new CorruptDatabaseException("File is smaller than expected"); } long magic = p_longGetLE(header, I_MAGIC_NUMBER); if (magic != MAGIC_NUMBER) { throw new CorruptDatabaseException("Wrong magic number: " + magic); } int checksum = p_intGetLE(header, I_CHECKSUM); int newChecksum = setHeaderChecksum(header); if (newChecksum != checksum) { throw new CorruptDatabaseException ("Header checksum mismatch: " + newChecksum + " != " + checksum); } return header; } catch (Throwable e) { p_delete(header); throw e; } }
private /*P*/ byte[] readHeader(int id) throws IOException { /*P*/ byte[] header = p_alloc(MINIMUM_PAGE_SIZE); try { try { mPageArray.readPage(id, header, 0, MINIMUM_PAGE_SIZE); } catch (EOFException e) { throw new CorruptDatabaseException("File is smaller than expected"); } long magic = p_longGetLE(header, I_MAGIC_NUMBER); if (magic != MAGIC_NUMBER) { throw new CorruptDatabaseException("Wrong magic number: " + magic); } int checksum = p_intGetLE(header, I_CHECKSUM); int newChecksum = setHeaderChecksum(header); if (newChecksum != checksum) { throw new CorruptDatabaseException ("Header checksum mismatch: " + newChecksum + " != " + checksum); } return header; } catch (Throwable e) { p_delete(header); throw e; } }
private /*P*/ byte[] readHeader(int id) throws IOException { /*P*/ byte[] header = p_alloc(MINIMUM_PAGE_SIZE, isDirectIO()); try { try { mPageArray.readPage(id, header, 0, MINIMUM_PAGE_SIZE); } catch (EOFException e) { throw new CorruptDatabaseException("File is smaller than expected"); } checkMagicNumber(p_longGetLE(header, I_MAGIC_NUMBER)); int checksum = p_intGetLE(header, I_CHECKSUM); int newChecksum = setHeaderChecksum(header); if (newChecksum != checksum) { throw new CorruptDatabaseException ("Header checksum mismatch: " + newChecksum + " != " + checksum); } return header; } catch (Throwable e) { p_delete(header); throw e; } }
setHeaderChecksum(header);