diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 1dbe69b22..e92fdcb02 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -341,6 +341,7 @@ public final class SWF implements TreeItem { /** * Faster constructor to check SWF only * @param is + * @throws java.io.IOException */ public SWF(InputStream is) throws IOException { byte[] hdr = new byte[3]; diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index 0a7293a48..ccd109547 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -854,7 +854,7 @@ public class SWFInputStream extends InputStream { while (true) { long pos = getPos(); try { - tag = readTag(swf, level, pos, parseTags && !parallel, parallel, skipUnusualTags, gfx); + tag = readTag(swf, level, pos, parseTags && !parallel, parallel, skipUnusualTags, gfx); } catch (EOFException | EndOfStreamException ex) { tag = null; } @@ -908,6 +908,7 @@ public class SWFInputStream extends InputStream { case SoundStreamHeadTag.ID: case SoundStreamHead2Tag.ID: case SoundStreamBlockTag.ID: + case VideoFrameTag.ID: doParse = true; break; default: @@ -941,7 +942,7 @@ public class SWFInputStream extends InputStream { } catch (ExecutionException e) { Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "Error during tag reading", e); } - } + } executor.shutdown(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFSourceInfo.java b/trunk/src/com/jpexs/decompiler/flash/SWFSourceInfo.java index 0c88f7924..948f29282 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFSourceInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFSourceInfo.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash; -import com.jpexs.helpers.Helper; +import com.jpexs.helpers.Path; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; @@ -70,7 +70,7 @@ public class SWFSourceInfo { if (fileName.startsWith("asdec_") && fileName.endsWith(".tmp")) { return false; } - String extension = Helper.getExtension(fileObj); + String extension = Path.getExtension(fileObj); return !(extension.equals(".swf") || extension.equals(".gfx")); } return false; @@ -81,7 +81,7 @@ public class SWFSourceInfo { return null; } - String extension = Helper.getExtension(new File(file)); + String extension = Path.getExtension(new File(file)); InputStream is = new BufferedInputStream(new FileInputStream(file)); switch (extension) { case ".swc": diff --git a/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index 6a2f1892f..5ee8d24e7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/trunk/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -30,6 +30,7 @@ import com.jpexs.decompiler.flash.gui.Main; import com.jpexs.decompiler.flash.xfl.FLAVersion; import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.helpers.Helper; +import com.jpexs.helpers.Path; import com.jpexs.helpers.streams.SeekableInputStream; import com.sun.jna.Platform; import com.sun.jna.platform.win32.Kernel32; @@ -123,8 +124,10 @@ public class CommandLineArgumentParser { System.out.println(" ...Compress SWF and save it to "); System.out.println(" 8) -decompress "); System.out.println(" ...Decompress and save it to "); - System.out.println(" 9) -extract [nocheck] [(all|biggest)]"); + System.out.println(" 9) -extract [-o |] [nocheck] [(all|biggest|first)]"); System.out.println(" ...Extracts SWF files from ZIP or other binary files"); + System.out.println(" ...-o parameter should contain a file path when \"biggest\" or \"first\" parameter is specified"); + System.out.println(" ...-o parameter should contain a folder path when no exctaction mode or \"all\" parameter is specified"); System.out.println(" 10) -renameInvalidIdentifiers (typeNumber|randomWord) e"); System.out.println(" ...Renames the invalid identifiers in and save it to "); System.out.println(" 11) -config key=value[,key2=value2][,key3=value3...] [other parameters]"); @@ -763,11 +766,19 @@ public class CommandLineArgumentParser { SearchMode mode = SearchMode.ALL; boolean noCheck = false; - if (args.size() > 0) { - if (args.peek().toLowerCase().equals("nocheck")) { - noCheck = true; - args.remove(); + String output = null; + + if (args.size() > 0 && args.peek().toLowerCase().equals("-o")) { + args.remove(); + if (args.size() < 1) { + badArguments(); } + output = args.remove(); + } + + if (args.size() > 0 && args.peek().toLowerCase().equals("nocheck")) { + noCheck = true; + args.remove(); } if (args.size() > 0) { @@ -798,9 +809,16 @@ public class CommandLineArgumentParser { stream.reset(); String fileNameOut; if (mode == SearchMode.BIGGEST) { - fileNameOut = Helper.getWithoutExtension(new File(fileName)) + ".swf"; + if (output == null) { + fileNameOut = Path.getFileNameWithoutExtension(new File(fileName)) + ".swf"; + } else { + fileNameOut = output; + } } else { fileNameOut = streamEntry.getKey() + ".swf"; + if (output != null) { + fileNameOut = Path.combine(output, fileNameOut); + } } try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(fileNameOut))) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index 5b0a154e9..0c0b71293 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -469,7 +469,7 @@ public class GenericTagTreePanel extends GenericTagPanel { private final Object mtroot; private final List listeners = new ArrayList<>(); - private Map nodeCache = new HashMap<>(); + private final Map nodeCache = new HashMap<>(); private Object getNodeByPath(String path) { if (nodeCache.containsKey(path)) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index 58df2166b..266505431 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -34,6 +34,7 @@ import com.jpexs.decompiler.flash.tags.base.FontTag; import com.jpexs.helpers.Cache; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; +import com.jpexs.helpers.Path; import com.jpexs.helpers.ProgressListener; import com.jpexs.helpers.Stopwatch; import com.jpexs.helpers.streams.SeekableInputStream; @@ -529,7 +530,7 @@ public class Main { case SAVE: case SAVEAS: if (swf.file != null) { - ext = Helper.getExtension(swf.file); + ext = Path.getExtension(swf.file); } break; case EXE: diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java index 197760af5..09eba68a5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrameRibbon.java @@ -35,10 +35,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.swing.JFrame; -import javax.swing.SwingUtilities; import org.pushingpixels.flamingo.api.common.AbstractCommandButton; import org.pushingpixels.flamingo.api.common.CommandButtonDisplayState; import org.pushingpixels.flamingo.api.common.CommandButtonLayoutManager; diff --git a/trunk/src/com/jpexs/helpers/Helper.java b/trunk/src/com/jpexs/helpers/Helper.java index 996f04b30..6f06a4faa 100644 --- a/trunk/src/com/jpexs/helpers/Helper.java +++ b/trunk/src/com/jpexs/helpers/Helper.java @@ -755,38 +755,6 @@ public class Helper { } } - /* - * Get the extension of a file. - */ - public static String getExtension(String fileName) { - return getExtension(new File(fileName)); - } - - /* - * Get the extension of a file. - */ - public static String getExtension(File f) { - String ext = null; - String s = f.getName(); - int i = s.lastIndexOf('.'); - - if (i > 0 && i < s.length() - 1) { - ext = s.substring(i).toLowerCase(); - } - return ext; - } - - public static String getWithoutExtension(File f) { - String ext = null; - String s = f.getName(); - int i = s.lastIndexOf('.'); - - if (i > 0 && i < s.length() - 1) { - ext = s.substring(0, i).toLowerCase(); - } - return ext; - } - public static void appendTimeoutComment(GraphTextWriter writer, int timeout) { writer.appendNoHilight("/*").newLine(); writer.appendNoHilight(" * ").appendNoHilight(AppStrings.translate("decompilationError")).newLine(); diff --git a/trunk/src/com/jpexs/helpers/Path.java b/trunk/src/com/jpexs/helpers/Path.java new file mode 100644 index 000000000..922b125a8 --- /dev/null +++ b/trunk/src/com/jpexs/helpers/Path.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2010-2014 PEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.helpers; + +import java.io.File; + +/** + * + * @author JPEXS + */ +public class Path { + + public static String combine(String... paths) { + String result = ""; + String separator = File.separator; + for (String path : paths) { + if (path.startsWith(separator)) { + result = result.substring(separator.length()); + } + if (!result.endsWith(separator)) { + result += separator; + } + result += path; + } + return result; + } + + /* + * Get the extension of a file. + */ + public static String getExtension(String fileName) { + return getExtension(new File(fileName)); + } + + /* + * Get the extension of a file. + */ + public static String getExtension(File f) { + String ext = null; + String s = f.getName(); + int i = s.lastIndexOf('.'); + + if (i > 0 && i < s.length() - 1) { + ext = s.substring(i).toLowerCase(); + } + return ext; + } + + public static String getFileNameWithoutExtension(File f) { + String ext = null; + String s = f.getName(); + int i = s.lastIndexOf('.'); + + if (i > 0 && i < s.length() - 1) { + ext = s.substring(0, i).toLowerCase(); + } + return ext; + } +}