From 421fbf8bc0e769456c84f6c2b43dcc3a1fa0e4c4 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 6 Mar 2016 17:14:35 +0100 Subject: [PATCH] export fla without scripts for debugging purposes --- .../src/com/jpexs/decompiler/flash/SWF.java | 14 +++-- .../decompiler/flash/xfl/XFLConverter.java | 4 +- .../flash/xfl/XFLExportSettings.java | 28 ++++++++++ .../console/CommandLineArgumentParser.java | 52 +++++++++++-------- 4 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLExportSettings.java diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index d4fc10b87..f529054d5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -142,6 +142,7 @@ import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.flash.types.annotations.SWFField; import com.jpexs.decompiler.flash.xfl.FLAVersion; import com.jpexs.decompiler.flash.xfl.XFLConverter; +import com.jpexs.decompiler.flash.xfl.XFLExportSettings; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -2424,12 +2425,19 @@ public final class SWF implements SWFContainerItem, Timelined { } public void exportFla(AbortRetryIgnoreHandler handler, String outfile, String swfName, String generator, String generatorVerName, String generatorVersion, boolean parallel, FLAVersion version) throws IOException, InterruptedException { - XFLConverter.convertSWF(handler, this, swfName, outfile, true, generator, generatorVerName, generatorVersion, parallel, version); - clearAllCache(); + XFLExportSettings settings = new XFLExportSettings(); + settings.compressed = true; + exportXfl(handler, outfile, swfName, generator, generatorVerName, generatorVersion, parallel, version, settings); } public void exportXfl(AbortRetryIgnoreHandler handler, String outfile, String swfName, String generator, String generatorVerName, String generatorVersion, boolean parallel, FLAVersion version) throws IOException, InterruptedException { - XFLConverter.convertSWF(handler, this, swfName, outfile, false, generator, generatorVerName, generatorVersion, parallel, version); + XFLExportSettings settings = new XFLExportSettings(); + settings.compressed = false; + exportXfl(handler, outfile, swfName, generator, generatorVerName, generatorVersion, parallel, version, settings); + } + + public void exportXfl(AbortRetryIgnoreHandler handler, String outfile, String swfName, String generator, String generatorVerName, String generatorVersion, boolean parallel, FLAVersion version, XFLExportSettings settings) throws IOException, InterruptedException { + XFLConverter.convertSWF(handler, this, swfName, outfile, settings, generator, generatorVerName, generatorVersion, parallel, version); clearAllCache(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 6554c80bf..4a81dfaee 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -2675,7 +2675,7 @@ public class XFLConverter { return ret.toString(); } - public static void convertSWF(AbortRetryIgnoreHandler handler, SWF swf, String swfFileName, String outfile, boolean compressed, String generator, String generatorVerName, String generatorVersion, boolean parallel, FLAVersion flaVersion) throws IOException, InterruptedException { + public static void convertSWF(AbortRetryIgnoreHandler handler, SWF swf, String swfFileName, String outfile, XFLExportSettings settings, String generator, String generatorVerName, String generatorVersion, boolean parallel, FLAVersion flaVersion) throws IOException, InterruptedException { FileAttributesTag fa = swf.getFileAttributes(); @@ -2998,7 +2998,7 @@ public class XFLConverter { publishSettings.append(""); String publishSettingsStr = publishSettings.toString(); - if (compressed) { + if (settings.compressed) { final String domDocumentF = domDocumentStr; final String publishSettingsF = publishSettingsStr; final String outfileF = outfile; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLExportSettings.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLExportSettings.java new file mode 100644 index 000000000..bef03ec83 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLExportSettings.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2010-2016 JPEXS, All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + */ +package com.jpexs.decompiler.flash.xfl; + +/** + * + * @author JPEXS + */ +public class XFLExportSettings { + + public boolean compressed; + + public boolean exportScript = true; +} diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index 29b673719..7a7414942 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -117,6 +117,7 @@ import com.jpexs.decompiler.flash.treeitems.SWFList; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.sound.SoundFormat; import com.jpexs.decompiler.flash.xfl.FLAVersion; +import com.jpexs.decompiler.flash.xfl.XFLExportSettings; import com.jpexs.decompiler.graph.CompilationException; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.helpers.CancellableWorker; @@ -1519,33 +1520,12 @@ public class CommandLineArgumentParser { if (exportFormats.contains("fla")) { System.out.println("Exporting FLA..."); - FLAVersion flaVersion = FLAVersion.fromString(formats.get("fla")); - if (flaVersion == null) { - flaVersion = FLAVersion.CS6; //Defaults to CS6 - } - String outFile = outDir; - if (multipleExportTypes) { - outFile = Path.combine(outFile, "fla"); - }; - - outFile = Path.combine(outFile, inFile.getName()); - swf.exportFla(handler, outFile, inFile.getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get(), flaVersion); + exportFla(true, outDir, inFile, swf, multipleExportTypes, formats, handler); } if (exportFormats.contains("xfl")) { System.out.println("Exporting XFL..."); - FLAVersion xflVersion = FLAVersion.fromString(formats.get("xfl")); - if (xflVersion == null) { - xflVersion = FLAVersion.CS6; //Defaults to CS6 - } - - String outFile = outDir; - if (multipleExportTypes) { - outFile = Path.combine(outFile, "xfl"); - }; - - outFile = Path.combine(outFile, inFile.getName()); - swf.exportXfl(handler, outFile, inFile.getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get(), xflVersion); + exportFla(false, outDir, inFile, swf, multipleExportTypes, formats, handler); } if (!singleFile) { @@ -1574,6 +1554,32 @@ public class CommandLineArgumentParser { System.exit(exportOK ? 0 : 1); } + private static void exportFla(boolean compressed, String outDir, File inFile, SWF swf, boolean multipleExportTypes, Map formats, AbortRetryIgnoreHandler handler) throws IOException, InterruptedException { + String exportFormat = compressed ? "fla" : "xfl"; + String format = formats.get(exportFormat); + boolean exportScript = true; + if (format != null && format.endsWith("_noscript")) { + format = format.substring(0, format.length() - 9); + exportScript = false; + } + + FLAVersion flaVersion = FLAVersion.fromString(format); + if (flaVersion == null) { + flaVersion = FLAVersion.CS6; //Defaults to CS6 + } + + String outFile = outDir; + if (multipleExportTypes) { + outFile = Path.combine(outFile, exportFormat); + }; + + outFile = Path.combine(outFile, inFile.getName()); + XFLExportSettings settings = new XFLExportSettings(); + settings.compressed = true; + settings.exportScript = exportScript; + swf.exportXfl(handler, outFile, inFile.getName(), ApplicationInfo.APPLICATION_NAME, ApplicationInfo.applicationVerName, ApplicationInfo.version, Configuration.parallelSpeedUp.get(), flaVersion, settings); + } + private static void parseDeobfuscate(Stack args) { if (args.size() < 3) { badArguments("deobfuscate");