|
40 | 40 | */ |
41 | 41 | public class ZipFile implements ArchiveFile { |
42 | 42 | Source r; |
43 | | - private Source fpRead; |
| 43 | + Source fpRead; |
44 | 44 | private static final long FPREAD_OFFSET = ReflectionUtils.fieldOffset(ZipFile.class, "fpRead"); |
45 | 45 |
|
46 | 46 | private static final XHashSet.Shape<String, ZEntry> ENTRY_SHAPE = XHashSet.noCreation(ZEntry.class, "name", "next"); |
47 | 47 |
|
48 | 48 | XHashSet<String, ZEntry> namedEntries; |
49 | | - SimpleList<ZEntry> entries; |
| 49 | + SimpleList<ZEntry> entries = new SimpleList<>(); |
50 | 50 |
|
51 | 51 | private ByteList buf; |
52 | 52 | final Charset cs; |
@@ -128,7 +128,7 @@ public void close() throws IOException { |
128 | 128 | } |
129 | 129 |
|
130 | 130 | public final void reload() throws IOException { |
131 | | - entries = new SimpleList<>(); |
| 131 | + entries.clear(); |
132 | 132 | namedEntries = null; |
133 | 133 | cDirLen = cDirOffset = 0; |
134 | 134 |
|
@@ -338,7 +338,7 @@ private void readLOC(SimpleList<ZEntry> locEntries) throws IOException { |
338 | 338 | // 8; HAS EXT |
339 | 339 | if ((flags & 8) != 0 && cSize == 0) { |
340 | 340 | // skip method |
341 | | - InflateIn in1 = (InflateIn) getCachedInflater(r.asInputStream()); |
| 341 | + InflateIn in1 = (InflateIn) getCachedInflater(new SourceInputStream(r, Long.MAX_VALUE, false)); |
342 | 342 | byte[] tmp = buf.list; |
343 | 343 | while (in1.read(tmp) >= 0); |
344 | 344 |
|
@@ -487,7 +487,8 @@ private void readEND64() throws IOException { |
487 | 487 | cDirOffset = buf.readLongLE(36); |
488 | 488 | } |
489 | 489 |
|
490 | | - private void verifyEntry(Source r, ZEntry entry) throws IOException { |
| 490 | + public void validateEntry(ZEntry entry) throws IOException {validateEntry(r, entry);} |
| 491 | + private void validateEntry(Source r, ZEntry entry) throws IOException { |
491 | 492 | if ((entry.mzFlag & ZEntry.MZ_ERROR) != 0 && (flags & FLAG_VERIFY) != 0) throw new ZipException(entry+"报告自身已损坏"); |
492 | 493 | if ((entry.mzFlag & ZEntry.MZ_BACKWARD) == 0) return; |
493 | 494 |
|
@@ -566,7 +567,7 @@ public final InputStream getFileStream(ZEntry entry) throws IOException { |
566 | 567 | Source src = (Source) u.getAndSetObject(this, FPREAD_OFFSET, null); |
567 | 568 | if (src == null) src = r.threadSafeCopy(); |
568 | 569 |
|
569 | | - verifyEntry(src, entry); |
| 570 | + validateEntry(src, entry); |
570 | 571 | src.seek(entry.offset); |
571 | 572 | return new SourceInputStream.Shared(src, entry.cSize, this, FPREAD_OFFSET); |
572 | 573 | } |
|
0 commit comments