diff --git a/trunk/src/com/jpexs/decompiler/flash/BinarySWFBundle.java b/trunk/src/com/jpexs/decompiler/flash/BinarySWFBundle.java index 6b7792102..9270c5e09 100644 --- a/trunk/src/com/jpexs/decompiler/flash/BinarySWFBundle.java +++ b/trunk/src/com/jpexs/decompiler/flash/BinarySWFBundle.java @@ -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 getAll() { - Map ret = new HashMap<>(); + public Map getAll() { + Map ret = new HashMap<>(); for(String key:getKeys()){ ret.put(key, getSWF(key)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index b2c2523f3..592ec6940 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -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 characters; public List abcList; diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFBundle.java b/trunk/src/com/jpexs/decompiler/flash/SWFBundle.java index 225d4971a..5e0102e55 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFBundle.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFBundle.java @@ -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 getKeys(); - public ReReadableInputStream getSWF(String key) throws IOException; - public Map getAll() throws IOException; + public SeekableInputStream getSWF(String key) throws IOException; + public Map getAll() throws IOException; public String getExtension(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFSourceInfo.java b/trunk/src/com/jpexs/decompiler/flash/SWFSourceInfo.java index bd801d2d2..699a32442 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFSourceInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFSourceInfo.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/ZippedSWFBundle.java b/trunk/src/com/jpexs/decompiler/flash/ZippedSWFBundle.java index 7c3fe33ff..c9ec0e669 100644 --- a/trunk/src/com/jpexs/decompiler/flash/ZippedSWFBundle.java +++ b/trunk/src/com/jpexs/decompiler/flash/ZippedSWFBundle.java @@ -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 keySet = new HashSet<>(); - private final Map cachedSWFs = new HashMap<>(); + private final Map 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 getAll() throws IOException { + public Map getAll() throws IOException { for(String key : getKeys()){ //cache everything first getSWF(key); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index 7028c43f2..e390c368d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -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 streamEntry : bundle.getAll().entrySet()) { + for (Entry 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 { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 9f72c97e9..e42ce4103 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -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 textSearchPanel; + private final SearchPanel textSearchPanel; private final LineMarkedEditorPane textValue; private final JSplitPane splitPane1; private final JSplitPane splitPane2; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java index 0b71524a7..9b79a2bd0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java @@ -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; diff --git a/trunk/src/com/jpexs/helpers/Helper.java b/trunk/src/com/jpexs/helpers/Helper.java index 1d2fda43c..74e42fb05 100644 --- a/trunk/src/com/jpexs/helpers/Helper.java +++ b/trunk/src/com/jpexs/helpers/Helper.java @@ -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) { diff --git a/trunk/src/com/sun/jna/platform/win32/Advapi32Util.java b/trunk/src/com/sun/jna/platform/win32/Advapi32Util.java index 8279f2fa3..fab474814 100644 --- a/trunk/src/com/sun/jna/platform/win32/Advapi32Util.java +++ b/trunk/src/com/sun/jna/platform/win32/Advapi32Util.java @@ -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;