/** * Create a new {@link CentralDirectoryEndRecord} instance from the specified * {@link RandomAccessData}, searching backwards from the end until a valid block is * located. * @param data the source data * @throws IOException in case of I/O errors */ CentralDirectoryEndRecord(RandomAccessData data) throws IOException { this.block = createBlockFromEndOfData(data, READ_BLOCK_SIZE); this.size = MINIMUM_SIZE; this.offset = this.block.length - this.size; while (!isValid()) { this.size++; if (this.size > this.block.length) { if (this.size >= MAXIMUM_SIZE || this.size > data.getSize()) { throw new IOException("Unable to find ZIP central directory " + "records after reading " + this.size + " bytes"); } this.block = createBlockFromEndOfData(data, this.size + READ_BLOCK_SIZE); } this.offset = this.block.length - this.size; } }