This commit is contained in:
Honfika
2014-02-27 13:42:59 +01:00
9 changed files with 107 additions and 48 deletions
@@ -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];
@@ -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();
}
@@ -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":
@@ -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 <infile> and save it to <outfile>");
System.out.println(" 8) -decompress <infile> <outfile>");
System.out.println(" ...Decompress <infile> and save it to <outfile>");
System.out.println(" 9) -extract <infile> [nocheck] [(all|biggest)]");
System.out.println(" 9) -extract <infile> [-o <outpath>|<outfile>] [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) <infile> <outfil>e");
System.out.println(" ...Renames the invalid identifiers in <infile> and save it to <outfile>");
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))) {
@@ -469,7 +469,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
private final Object mtroot;
private final List<TreeModelListener> listeners = new ArrayList<>();
private Map<String, Object> nodeCache = new HashMap<>();
private final Map<String, Object> nodeCache = new HashMap<>();
private Object getNodeByPath(String path) {
if (nodeCache.containsKey(path)) {
@@ -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:
@@ -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;
-32
View File
@@ -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();
+73
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
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;
}
}