small fixes, but binary search still not working

This commit is contained in:
Honfika
2014-01-21 22:52:15 +01:00
parent fc92a2e5b5
commit 7b518a6e0d
5 changed files with 18 additions and 15 deletions

View File

@@ -34,7 +34,8 @@ import java.util.Set;
public class BinarySWFBundle implements SWFBundle {
private final SWFSearch search;
public BinarySWFBundle(InputStream is){
search = new SWFSearch(new StreamSearch(is));
search = new SWFSearch(new StreamSearch(is));
search.process();
}
@Override
@@ -44,9 +45,9 @@ public class BinarySWFBundle implements SWFBundle {
@Override
public Set<String> getKeys() {
Set<String> ret=new HashSet<>();
for(int i=0;i<length();i++){
ret.add("["+i+"]");
Set<String> ret = new HashSet<>();
for(int i = 0; i < length(); i++){
ret.add("[" + i + "]");
}
return ret;
}

View File

@@ -78,12 +78,13 @@ public class SWFSearch {
setProgress(pos * 100 / ret.size());
pos++;
try {
PosMarkedInputStream pmi = new PosMarkedInputStream(ret.get(addr));
ReReadableInputStream is = new ReReadableInputStream(pmi);
SWF swf = new SWF(is, null, false, true);
ReReadableInputStream ris = (ReReadableInputStream) ret.get(addr);
ris.reset();
PosMarkedInputStream pmi = new PosMarkedInputStream(ris);
SWF swf = new SWF(pmi, null, false, true);
long limit = pmi.getPos();
is.seek(0);
is = new ReReadableInputStream(new LimitedInputStream(is, limit));
ris.seek(0);
ReReadableInputStream is = new ReReadableInputStream(new LimitedInputStream(ris, limit));
if (swf.fileSize > 0 && swf.version > 0 && !swf.tags.isEmpty() && swf.version < 25/*Needs to be fixed when SWF versions reaches this value*/) {
swfStreams.add(is);
}

View File

@@ -27,9 +27,9 @@ import java.io.InputStream;
public class FoundInputStream extends ReReadableInputStream{
private final long startPos;
private boolean started=false;
private boolean started = false;
public FoundInputStream(long startPos,InputStream is) {
public FoundInputStream(long startPos, InputStream is) {
super(is);
this.startPos = startPos;
}
@@ -47,11 +47,11 @@ public class FoundInputStream extends ReReadableInputStream{
@Override
public void seek(long pos) throws IOException {
super.seek(pos+startPos);
super.seek(pos + startPos);
}
@Override
public long getPos() {
return super.getPos()-startPos;
return super.getPos() - startPos;
}
}

View File

@@ -83,7 +83,8 @@ public class StreamSearch implements Searchable {
}
}
if (match) {
ret.put(pos+i, new FoundInputStream(pos+i,is));
InputStream fis = new FoundInputStream(pos + i, is);
ret.put(pos + i, fis);
continue loopdata;
}
}

View File

@@ -26,7 +26,7 @@ import java.util.Map;
*
* @author JPEXS
*/
public interface Process extends Comparable<Process>, Searchable{
public interface Process extends Comparable<Process>, Searchable {
public String getFilePath();