|
2 | 2 |
|
3 | 3 | import software.coley.llzip.format.compression.ZipCompressions; |
4 | 4 | import software.coley.llzip.util.ByteData; |
| 5 | +import software.coley.llzip.util.lazy.LazyInt; |
| 6 | +import software.coley.llzip.util.lazy.LazyLong; |
5 | 7 |
|
6 | 8 | import java.util.NavigableSet; |
7 | 9 |
|
@@ -39,8 +41,10 @@ public void read(ByteData data, long offset) { |
39 | 41 | this.dataOffsetStart = dataOffsetStart; |
40 | 42 | this.dataOffsetEnd = dataOffsetEnd == null ? -1 : dataOffsetEnd; |
41 | 43 | if (dataOffsetEnd != null) { |
42 | | - // Valid data range found |
43 | | - setFileData(data.slice(dataOffsetStart, dataOffsetEnd)); |
| 44 | + // Valid data range found, map back to (localOffset, range) |
| 45 | + fileData = readLongSlice(data, |
| 46 | + new LazyLong(() -> dataOffsetStart - offset), |
| 47 | + new LazyLong(() -> dataOffsetEnd - offset)); |
44 | 48 | foundData = true; |
45 | 49 | } else { |
46 | 50 | // Keep data reference to attempt restoration with later when linking to the CEN. |
@@ -78,7 +82,9 @@ public void link(CentralDirectoryFileHeader directoryFileHeader) { |
78 | 82 | // Data should not be overflowing into adjacent header entries. |
79 | 83 | // - If it is, the data here is likely intentionally tampered with to screw with parsers |
80 | 84 | if (fileDataLength + offset < dataOffsetEnd) { |
81 | | - setFileData(data.sliceOf(dataOffsetStart, fileDataLength)); |
| 85 | + fileData = readLongSlice(data, |
| 86 | + new LazyLong(() -> dataOffsetStart - offset), |
| 87 | + new LazyLong(() -> fileDataLength)); |
82 | 88 | data = null; |
83 | 89 | } |
84 | 90 | } |
|
0 commit comments