()
| 130 | } |
| 131 | |
| 132 | private EocdRecord readEocdRecord() throws IOException { |
| 133 | boolean found = false; |
| 134 | long length = _length(); |
| 135 | long off = length - MIN_EOCD_SIZE; |
| 136 | final long stopSearching = Math.max(0L, length - MAX_EOCD_SIZE); |
| 137 | while (off >= stopSearching) { |
| 138 | _seek(off); |
| 139 | if (_readInt() == EOCD_SIG) { |
| 140 | found = true; |
| 141 | break; |
| 142 | } |
| 143 | off--; |
| 144 | } |
| 145 | if (!found) { |
| 146 | return null; |
| 147 | } |
| 148 | |
| 149 | try { |
| 150 | final long zip64EocdRecordOffset = parseZip64EocdRecordLocator(off); |
| 151 | |
| 152 | EocdRecord record = parseEocdRecord(off + 4, (zip64EocdRecordOffset != -1) /* isZip64 */); |
| 153 | if (record.commentLength > 0) { |
| 154 | try { |
| 155 | _readBytes(record.commentLength); |
| 156 | } catch (IOException ignored) { |
| 157 | record = new EocdRecord(record.numEntries, record.centralDirOffset, 0, record.zip64); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | if (zip64EocdRecordOffset != -1) { |
| 162 | record = parseZip64EocdRecord(zip64EocdRecordOffset, record.commentLength); |
| 163 | } |
| 164 | |
| 165 | return record; |
| 166 | } catch (IOException e) { |
| 167 | e.printStackTrace(); |
| 168 | return null; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | private long parseZip64EocdRecordLocator(long eocdOffset) |
| 173 | throws IOException { |
no test coverage detected