Fixed #1757 Binary search - SWF files need to be sorted by file position

This commit is contained in:
Jindra Petřík
2022-11-17 20:23:37 +01:00
parent a41e3d13fa
commit 1e535a4472
5 changed files with 13 additions and 6 deletions

View File

@@ -19,6 +19,7 @@ package com.jpexs.helpers;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -42,7 +43,7 @@ public class StreamSearch implements Searchable {
@Override
public Map<Long, InputStream> search(ProgressListener progListener, byte[]... data) {
Map<Long, InputStream> ret = new HashMap<>();
Map<Long, InputStream> ret = new LinkedHashMap<>();
int maxFindLen = 0;
for (int i = 0; i < data.length; i++) {
if (data[i].length > maxFindLen) {
@@ -84,7 +85,7 @@ public class StreamSearch implements Searchable {
}
if (match) {
// todo: support > 2GB files
InputStream fis = new MemoryInputStream(is.getAllRead(), (int) pos + i);
InputStream fis = new MemoryInputStream(is.getAllRead(), (int) pos + i);
ret.put(pos + i, fis);
continue loopdata;
}