MCPcopy Index your code
hub / github.com/dumbledore/AlbiteREADER / readEntries

Method readEntries

src/gnu/zip/ZipFile.java:226–292  ·  view source on GitHub ↗

Read the central directory of a zip file and fill the entries array. This is called exactly once when first needed. It is called while holding the lock on raf . @exception IOException if a i/o error occured. @exception ZipException if the central directory is malformed

()

Source from the content-addressed store, hash-verified

224 * @exception ZipException if the central directory is malformed
225 */
226 private void readEntries() throws ZipException, IOException
227 {
228 /* Search for the End Of Central Directory. When a zip comment is
229 * present the directory may start earlier.
230 * Note that a comment has a maximum length of 64K, so that is the
231 * maximum we search backwards.
232 */
233 PartialInputStream inp = new PartialInputStream(rrf, 4096);
234 long pos = rrf.length() - ENDHDR;
235 long top = Math.max(0, pos - 65536);
236 do
237 {
238 if (pos < top)
239 throw new ZipException
240 ("central directory not found, probably not a zip file: " + name);
241 inp.seek(pos--);
242 }
243 while (inp.readLeInt() != ENDSIG);
244
245 if (inp.skip(ENDTOT - ENDNRD) != ENDTOT - ENDNRD)
246 throw new EOFException(name);
247 int count = inp.readLeShort();
248 if (inp.skip(ENDOFF - ENDSIZ) != ENDOFF - ENDSIZ)
249 throw new EOFException(name);
250 int centralOffset = inp.readLeInt();
251
252 entries = new Hashtable(count+count/2);
253 inp.seek(centralOffset);
254
255 for (int i = 0; i < count; i++)
256 {
257 if (inp.readLeInt() != CENSIG)
258 throw new ZipException("Wrong Central Directory signature: " + name);
259
260 inp.skip(6);
261 int method = inp.readLeShort();
262 int dostime = inp.readLeInt();
263 int crc = inp.readLeInt();
264 int csize = inp.readLeInt();
265 int size = inp.readLeInt();
266 int nameLen = inp.readLeShort();
267 int extraLen = inp.readLeShort();
268 int commentLen = inp.readLeShort();
269 inp.skip(8);
270 int offset = inp.readLeInt();
271 String name = inp.readString(nameLen);
272
273 ZipEntry entry = new ZipEntry(name);
274 entry.setMethod(method);
275 entry.setCrc(crc & 0xffffffffL);
276 entry.setSize(size & 0xffffffffL);
277 entry.setCompressedSize(csize & 0xffffffffL);
278 entry.setDOSTime(dostime);
279 if (extraLen > 0)
280 {
281 byte[] extra = new byte[extraLen];
282 inp.readFully(extra);
283 entry.setExtra(extra);

Callers 1

getEntriesMethod · 0.95

Calls 14

seekMethod · 0.95
readLeIntMethod · 0.95
skipMethod · 0.95
readLeShortMethod · 0.95
readStringMethod · 0.95
setMethodMethod · 0.95
setCrcMethod · 0.95
setSizeMethod · 0.95
setCompressedSizeMethod · 0.95
setDOSTimeMethod · 0.95
readFullyMethod · 0.95
setExtraMethod · 0.95

Tested by

no test coverage detected