zip bundle fixed

This commit is contained in:
Honfika
2014-01-21 22:20:01 +01:00
parent e1f37eb0b6
commit fc92a2e5b5
10 changed files with 33 additions and 20 deletions

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash;
import com.jpexs.helpers.ReReadableInputStream;
import com.jpexs.helpers.StreamSearch;
import com.jpexs.helpers.streams.SeekableInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@@ -73,8 +74,8 @@ public class BinarySWFBundle implements SWFBundle {
}
@Override
public Map<String, ReReadableInputStream> getAll() {
Map<String, ReReadableInputStream> ret = new HashMap<>();
public Map<String, SeekableInputStream> getAll() {
Map<String, SeekableInputStream> ret = new HashMap<>();
for(String key:getKeys()){
ret.put(key, getSWF(key));
}

View File

@@ -220,6 +220,7 @@ public final class SWF implements TreeItem {
public SWFList swfList;
public String file;
public String fileTitle;
public boolean readOnly;
public boolean isAS3;
public HashMap<Integer, CharacterTag> characters;
public List<ABCContainerTag> abcList;

View File

@@ -17,8 +17,7 @@
package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.treeitems.TreeItem;
import com.jpexs.helpers.ReReadableInputStream;
import com.jpexs.helpers.streams.SeekableInputStream;
import java.io.IOException;
import java.util.Map;
import java.util.Set;
@@ -31,7 +30,7 @@ public interface SWFBundle {
public int length();
public Set<String> getKeys();
public ReReadableInputStream getSWF(String key) throws IOException;
public Map<String, ReReadableInputStream> getAll() throws IOException;
public SeekableInputStream getSWF(String key) throws IOException;
public Map<String, SeekableInputStream> getAll() throws IOException;
public String getExtension();
}

View File

@@ -20,8 +20,6 @@ import com.jpexs.helpers.Helper;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

View File

@@ -17,8 +17,10 @@
package com.jpexs.decompiler.flash;
import com.jpexs.helpers.LimitedInputStream;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.MemoryInputStream;
import com.jpexs.helpers.ReReadableInputStream;
import com.jpexs.helpers.streams.SeekableInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@@ -36,7 +38,7 @@ import java.util.zip.ZipInputStream;
*/
public class ZippedSWFBundle implements SWFBundle {
protected Set<String> keySet = new HashSet<>();
private final Map<String, ReReadableInputStream> cachedSWFs = new HashMap<>();
private final Map<String, SeekableInputStream> cachedSWFs = new HashMap<>();
protected ReReadableInputStream is;
@@ -69,7 +71,7 @@ public class ZippedSWFBundle implements SWFBundle {
}
@Override
public ReReadableInputStream getSWF(String key) throws IOException {
public SeekableInputStream getSWF(String key) throws IOException {
if(!keySet.contains(key)){
return null;
}
@@ -82,8 +84,8 @@ public class ZippedSWFBundle implements SWFBundle {
while((entry = zip.getNextEntry()) != null)
{
if(entry.getName().equals(key)){
ReReadableInputStream ris = new ReReadableInputStream(zip);
cachedSWFs.put(key, ris);
MemoryInputStream mis = new MemoryInputStream(Helper.readStream(zip));
cachedSWFs.put(key, mis);
break;
}
zip.closeEntry();
@@ -98,7 +100,7 @@ public class ZippedSWFBundle implements SWFBundle {
}
@Override
public Map<String, ReReadableInputStream> getAll() throws IOException {
public Map<String, SeekableInputStream> getAll() throws IOException {
for(String key : getKeys()){ //cache everything first
getSWF(key);
}

View File

@@ -34,7 +34,6 @@ import com.jpexs.helpers.Cache;
import com.jpexs.helpers.CancellableWorker;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.ProgressListener;
import com.jpexs.helpers.ReReadableInputStream;
import com.jpexs.helpers.Stopwatch;
import com.jpexs.helpers.streams.SeekableInputStream;
import com.sun.jna.Platform;
@@ -233,7 +232,7 @@ public class Main {
if (bundle != null) {
result.isBundle = true;
result.name = new File(sourceInfo.getFileTitleOrName()).getName();
for (Entry<String, ReReadableInputStream> streamEntry : bundle.getAll().entrySet()) {
for (Entry<String, SeekableInputStream> streamEntry : bundle.getAll().entrySet()) {
InputStream stream = streamEntry.getValue();
stream.reset();
SWF swf = new SWF(stream, new ProgressListener() {
@@ -244,6 +243,7 @@ public class Main {
}, Configuration.parallelSpeedUp.get());
swf.file = sourceInfo.getFile();
swf.fileTitle = streamEntry.getKey();
swf.readOnly = true;
result.add(swf);
}
} else {

View File

@@ -21,7 +21,6 @@ import com.jpexs.decompiler.flash.AppStrings;
import com.jpexs.decompiler.flash.ApplicationInfo;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.SWFSourceInfo;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.RenameType;
import com.jpexs.decompiler.flash.abc.ScriptPack;
@@ -227,7 +226,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
private static final String INTERNAL_VIEWER_CARD = "INTERNALVIEWER";
private static final String SPLIT_PANE1 = "SPLITPANE1";
private static final String WELCOME_PANEL = "WELCOMEPANEL";
private SearchPanel<TextTag> textSearchPanel;
private final SearchPanel<TextTag> textSearchPanel;
private final LineMarkedEditorPane textValue;
private final JSplitPane splitPane1;
private final JSplitPane splitPane2;

View File

@@ -38,7 +38,6 @@ import com.jpexs.decompiler.flash.treeitems.TreeItem;
import com.jpexs.decompiler.flash.treenodes.ContainerNode;
import com.jpexs.decompiler.flash.treenodes.FrameNode;
import com.jpexs.decompiler.flash.treenodes.TreeNode;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

View File

@@ -410,6 +410,20 @@ public class Helper {
return baos.toByteArray();
}
public static byte[] readStream(InputStream is) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
byte[] buf = new byte[4096];
int cnt = 0;
while ((cnt = is.read(buf)) > 0) {
baos.write(buf, 0, cnt);
}
} catch (IOException ex) {
Logger.getLogger(Helper.class.getName()).log(Level.SEVERE, null, ex);
}
return baos.toByteArray();
}
public static void writeFile(String file, byte[]... data) {
try (FileOutputStream fos = new FileOutputStream(file)) {
for (byte[] d : data) {

View File

@@ -854,7 +854,7 @@ public abstract class Advapi32Util {
public static class EventLogRecord {
private EVENTLOGRECORD _record = null;
private String _source;
private final String _source;
private byte[] _data;
private String[] _strings;