mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-03 11:54:18 +00:00
#737 Exporting Scripts to single file
This commit is contained in:
@@ -352,7 +352,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
|
||||
di.getChildInfos().clear();
|
||||
}
|
||||
|
||||
|
||||
public Map<Integer, CharacterTag> getCharacters() {
|
||||
if (characters == null) {
|
||||
synchronized (this) {
|
||||
@@ -1259,7 +1259,6 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
if (!outdir.endsWith(File.separator)) {
|
||||
outdir += File.separator;
|
||||
}
|
||||
outdir += "scripts" + File.separator;
|
||||
|
||||
ret.addAll(new AS2ScriptExporter().exportAS2ScriptsTimeout(handler, outdir, getASMs(true), exportSettings, evl));
|
||||
return ret;
|
||||
@@ -1941,7 +1940,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
cnt++;
|
||||
informListeners("rename", "class " + cnt + "/" + classCount);
|
||||
DoInitActionTag dia = (DoInitActionTag) t;
|
||||
String exportName = characters.containsKey(dia.spriteId)?characters.get(dia.spriteId).getExportName():"_unk_";
|
||||
String exportName = characters.containsKey(dia.spriteId) ? characters.get(dia.spriteId).getExportName() : "_unk_";
|
||||
final String pkgPrefix = "__Packages.";
|
||||
String[] classNameParts = null;
|
||||
if ((exportName != null) && exportName.startsWith(pkgPrefix)) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.jpexs.decompiler.flash.helpers.NulWriter;
|
||||
import com.jpexs.decompiler.flash.treeitems.AS3ClassTreeItem;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -188,22 +189,21 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
}
|
||||
|
||||
public File export(String directory, ScriptExportSettings exportSettings, boolean parallel) throws IOException {
|
||||
String scriptName = getPathScriptName();
|
||||
String packageName = getPathPackage();
|
||||
File outDir = new File(directory + File.separatorChar + "scripts" + File.separatorChar + makeDirPath(packageName));
|
||||
if (!outDir.exists()) {
|
||||
if (!outDir.mkdirs()) {
|
||||
if (!outDir.exists()) {
|
||||
throw new IOException("cannot create directory " + outDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
String fileName = outDir.toString() + File.separator + Helper.makeFileName(scriptName) + ".as";
|
||||
File file = null;
|
||||
|
||||
File file = new File(fileName);
|
||||
try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(file))) {
|
||||
if (!exportSettings.singleFile) {
|
||||
String scriptName = getPathScriptName();
|
||||
String packageName = getPathPackage();
|
||||
File outDir = new File(directory + File.separatorChar + makeDirPath(packageName));
|
||||
Path.createDirectorySafe(outDir);
|
||||
String fileName = outDir.toString() + File.separator + Helper.makeFileName(scriptName) + ".as";
|
||||
file = new File(fileName);
|
||||
}
|
||||
|
||||
try (FileTextWriter writer = exportSettings.singleFile ? null : new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(file))) {
|
||||
try {
|
||||
toSource(writer, abc.script_info.get(scriptIndex).traits.traits, exportSettings.mode, parallel);
|
||||
FileTextWriter writer2 = exportSettings.singleFile ? exportSettings.singleFileWriter : writer;
|
||||
toSource(writer2, abc.script_info.get(scriptIndex).traits.traits, exportSettings.mode, parallel);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(ScriptPack.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -248,6 +248,4 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
public boolean isModified() {
|
||||
return abc.script_info.get(scriptIndex).isModified();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -329,6 +329,10 @@ public class Configuration {
|
||||
@ConfigurationCategory("export")
|
||||
public static final ConfigurationItem<Boolean> textExportSingleFile = null;
|
||||
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationCategory("export")
|
||||
public static final ConfigurationItem<Boolean> scriptExportSingleFile = null;
|
||||
|
||||
@ConfigurationDefaultString("--- SEPARATOR ---")
|
||||
@ConfigurationCategory("export")
|
||||
public static final ConfigurationItem<String> textExportSingleFileSeparator = null;
|
||||
@@ -420,8 +424,7 @@ public class Configuration {
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationCategory("ui")
|
||||
public static final ConfigurationItem<Boolean> saveSessionOnExit = null;
|
||||
|
||||
|
||||
|
||||
@ConfigurationDefaultBoolean(true)
|
||||
@ConfigurationCategory("ui")
|
||||
public static final ConfigurationItem<Boolean> allowOnlyOneInstance = null;
|
||||
@@ -760,6 +763,4 @@ public class Configuration {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.RunnableIOEx;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.BinaryDataExportSettings;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.helpers.Path;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -40,14 +41,9 @@ public class BinaryDataExporter {
|
||||
if (tags.isEmpty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
File foutdir = new File(outdir);
|
||||
if (!foutdir.exists()) {
|
||||
if (!foutdir.mkdirs()) {
|
||||
if (!foutdir.exists()) {
|
||||
throw new IOException("Cannot create directory " + outdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Path.createDirectorySafe(foutdir);
|
||||
|
||||
int count = 0;
|
||||
for (Tag t : tags) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
import com.jpexs.decompiler.flash.types.SHAPE;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import fontastic.FGlyph;
|
||||
import fontastic.FPoint;
|
||||
import fontastic.Fontastic;
|
||||
@@ -58,14 +59,9 @@ public class FontExporter {
|
||||
if (tags.isEmpty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
File foutdir = new File(outdir);
|
||||
if (!foutdir.exists()) {
|
||||
if (!foutdir.mkdirs()) {
|
||||
if (!foutdir.exists()) {
|
||||
throw new IOException("Cannot create directory " + outdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Path.createDirectorySafe(foutdir);
|
||||
|
||||
int count = 0;
|
||||
for (Tag t : tags) {
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.jpexs.decompiler.flash.types.filters.GLOWFILTER;
|
||||
import com.jpexs.decompiler.flash.types.filters.GRADIENTBEVELFILTER;
|
||||
import com.jpexs.decompiler.flash.types.filters.GRADIENTGLOWFILTER;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import gnu.jpdf.PDFJob;
|
||||
import java.awt.Color;
|
||||
@@ -110,13 +111,7 @@ public class FrameExporter {
|
||||
}
|
||||
|
||||
final File foutdir = new File(outdir + path);
|
||||
if (!foutdir.exists()) {
|
||||
if (!foutdir.mkdirs()) {
|
||||
if (!foutdir.exists()) {
|
||||
throw new IOException("Cannot create directory " + outdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Path.createDirectorySafe(foutdir);
|
||||
|
||||
final List<Integer> fframes = frames;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.helpers.ImageHelper;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ImageTag;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -44,14 +45,9 @@ public class ImageExporter {
|
||||
if (tags.isEmpty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
File foutdir = new File(outdir);
|
||||
if (!foutdir.exists()) {
|
||||
if (!foutdir.mkdirs()) {
|
||||
if (!foutdir.exists()) {
|
||||
throw new IOException("Cannot create directory " + outdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Path.createDirectorySafe(foutdir);
|
||||
|
||||
int count = 0;
|
||||
for (Tag t : tags) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MorphShapeTag;
|
||||
import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
@@ -54,14 +55,9 @@ public class MorphShapeExporter {
|
||||
if (tags.isEmpty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
File foutdir = new File(outdir);
|
||||
if (!foutdir.exists()) {
|
||||
if (!foutdir.mkdirs()) {
|
||||
if (!foutdir.exists()) {
|
||||
throw new IOException("Cannot create directory " + outdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Path.createDirectorySafe(foutdir);
|
||||
|
||||
int count = 0;
|
||||
for (Tag t : tags) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.VideoFrameTag;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -52,14 +53,9 @@ public class MovieExporter {
|
||||
if (tags.isEmpty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
File foutdir = new File(outdir);
|
||||
if (!foutdir.exists()) {
|
||||
if (!foutdir.mkdirs()) {
|
||||
if (!foutdir.exists()) {
|
||||
throw new IOException("Cannot create directory " + outdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Path.createDirectorySafe(foutdir);
|
||||
|
||||
int count = 0;
|
||||
for (Tag t : tags) {
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
import com.jpexs.decompiler.flash.types.SHAPE;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -59,14 +60,9 @@ public class ShapeExporter {
|
||||
if (tags.isEmpty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
File foutdir = new File(outdir);
|
||||
if (!foutdir.exists()) {
|
||||
if (!foutdir.mkdirs()) {
|
||||
if (!foutdir.exists()) {
|
||||
throw new IOException("Cannot create directory " + outdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Path.createDirectorySafe(foutdir);
|
||||
|
||||
int count = 0;
|
||||
for (Tag t : tags) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.SoundTag;
|
||||
import com.jpexs.decompiler.flash.types.sound.SoundFormat;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
@@ -55,14 +56,9 @@ public class SoundExporter {
|
||||
if (tags.isEmpty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
File foutdir = new File(outdir);
|
||||
if (!foutdir.exists()) {
|
||||
if (!foutdir.mkdirs()) {
|
||||
if (!foutdir.exists()) {
|
||||
throw new IOException("Cannot create directory " + outdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Path.createDirectorySafe(foutdir);
|
||||
|
||||
int count = 0;
|
||||
for (Tag t : tags) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
|
||||
import com.jpexs.decompiler.flash.tags.SymbolClassTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import com.jpexs.helpers.utf8.Utf8OutputStreamWriter;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
@@ -52,13 +53,7 @@ public class SymbolClassExporter {
|
||||
}
|
||||
|
||||
File foutdir = new File(outdir);
|
||||
if (!foutdir.exists()) {
|
||||
if (!foutdir.mkdirs()) {
|
||||
if (!foutdir.exists()) {
|
||||
throw new IOException("Cannot create directory " + outdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Path.createDirectorySafe(foutdir);
|
||||
|
||||
final File file = new File(outdir + File.separator + SYMBOL_CLASS_EXPORT_FILENAME);
|
||||
try (Writer writer = new BufferedWriter(new Utf8OutputStreamWriter(new FileOutputStream(file)))) {
|
||||
|
||||
@@ -54,14 +54,9 @@ public class TextExporter {
|
||||
if (tags.isEmpty()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
File foutdir = new File(outdir);
|
||||
if (!foutdir.exists()) {
|
||||
if (!foutdir.mkdirs()) {
|
||||
if (!foutdir.exists()) {
|
||||
throw new IOException("Cannot create directory " + outdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Path.createDirectorySafe(foutdir);
|
||||
|
||||
int count = 0;
|
||||
for (Tag t : tags) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
import com.jpexs.decompiler.graph.TranslateException;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -112,13 +113,8 @@ public class AS2ScriptExporter {
|
||||
try {
|
||||
int currentIndex = index.getAndIncrement();
|
||||
|
||||
File dir = new File(outdir);
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdirs()) {
|
||||
if (!dir.exists()) {
|
||||
throw new IOException("Cannot create directory " + outdir);
|
||||
}
|
||||
}
|
||||
if (!exportSettings.singleFile) {
|
||||
Path.createDirectorySafe(new File(outdir));
|
||||
}
|
||||
|
||||
String f = outdir + name + ".as";
|
||||
@@ -129,20 +125,21 @@ public class AS2ScriptExporter {
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
File file = new File(f);
|
||||
try (FileTextWriter writer = new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(f))) {
|
||||
try (FileTextWriter writer = exportSettings.singleFile ? null : new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(f))) {
|
||||
FileTextWriter writer2 = exportSettings.singleFile ? exportSettings.singleFileWriter : writer;
|
||||
ScriptExportMode exportMode = exportSettings.mode;
|
||||
if (exportMode == ScriptExportMode.HEX) {
|
||||
asm.getActionSourcePrefix(writer);
|
||||
asm.getActionBytesAsHex(writer);
|
||||
asm.getActionSourceSuffix(writer);
|
||||
asm.getActionSourcePrefix(writer2);
|
||||
asm.getActionBytesAsHex(writer2);
|
||||
asm.getActionSourceSuffix(writer2);
|
||||
} else if (exportMode != ScriptExportMode.AS) {
|
||||
asm.getActionSourcePrefix(writer);
|
||||
asm.getASMSource(exportMode, writer, null);
|
||||
asm.getActionSourceSuffix(writer);
|
||||
asm.getActionSourcePrefix(writer2);
|
||||
asm.getASMSource(exportMode, writer2, null);
|
||||
asm.getActionSourceSuffix(writer2);
|
||||
} else {
|
||||
List<Action> as = asm.getActions();
|
||||
Action.setActionsAddresses(as, 0);
|
||||
Action.actionsToSource(asm, as, ""/*FIXME*/, writer);
|
||||
Action.actionsToSource(asm, as, ""/*FIXME*/, writer2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.exporters.settings;
|
||||
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.helpers.FileTextWriter;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -28,6 +29,8 @@ public class ScriptExportSettings {
|
||||
|
||||
public boolean singleFile;
|
||||
|
||||
public FileTextWriter singleFileWriter;
|
||||
|
||||
public ScriptExportSettings(ScriptExportMode mode, boolean singleFile) {
|
||||
this.mode = mode;
|
||||
this.singleFile = singleFile;
|
||||
|
||||
@@ -16,18 +16,11 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.helpers.ByteArrayRange;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface CharacterIdTag {
|
||||
|
||||
|
||||
|
||||
public int getCharacterId();
|
||||
|
||||
}
|
||||
|
||||
@@ -103,6 +103,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord;
|
||||
import com.jpexs.decompiler.flash.types.sound.MP3FRAME;
|
||||
import com.jpexs.decompiler.flash.types.sound.MP3SOUNDDATA;
|
||||
import com.jpexs.decompiler.flash.types.sound.SoundFormat;
|
||||
import com.jpexs.helpers.Path;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.awt.Font;
|
||||
@@ -2675,13 +2676,7 @@ public class XFLConverter {
|
||||
}
|
||||
File file = new File(outfile);
|
||||
File outDir = file.getParentFile();
|
||||
if (!outDir.exists()) {
|
||||
if (!outDir.mkdirs()) {
|
||||
if (!outDir.exists()) {
|
||||
throw new IOException("cannot create directory " + outDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Path.createDirectorySafe(outDir);
|
||||
StringBuilder domDocument = new StringBuilder();
|
||||
String baseName = swfFileName;
|
||||
File f = new File(baseName);
|
||||
@@ -2733,9 +2728,9 @@ public class XFLConverter {
|
||||
DefineSpriteTag sprite = (DefineSpriteTag) characters.get(chid);
|
||||
if (sprite.subTags.isEmpty()) {
|
||||
String data = convertActionScript(dia);
|
||||
CharacterTag spr=dia.getSwf().getCharacter(dia.spriteId);
|
||||
String expName = spr!=null?spr.getExportName():"_unk_";
|
||||
|
||||
CharacterTag spr = dia.getSwf().getCharacter(dia.spriteId);
|
||||
String expName = spr != null ? spr.getExportName() : "_unk_";
|
||||
|
||||
String expPath = spr.getExportName();
|
||||
final String prefix = "__Packages.";
|
||||
if (expPath.startsWith(prefix)) {
|
||||
@@ -2748,13 +2743,7 @@ public class XFLConverter {
|
||||
}
|
||||
expPath = expPath.replace(".", File.separator);
|
||||
File cdir = new File(outDir.getAbsolutePath() + File.separator + expDir);
|
||||
if (!cdir.exists()) {
|
||||
if (!cdir.mkdirs()) {
|
||||
if (!cdir.exists()) {
|
||||
throw new IOException("cannot create directory " + cdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Path.createDirectorySafe(cdir);
|
||||
writeFile(handler, Utf8Helper.getBytes(data), outDir.getAbsolutePath() + File.separator + expPath + ".as");
|
||||
}
|
||||
}
|
||||
@@ -3021,14 +3010,7 @@ public class XFLConverter {
|
||||
}, handler).run();
|
||||
|
||||
} else {
|
||||
|
||||
if (!outDir.exists()) {
|
||||
if (!outDir.mkdirs()) {
|
||||
if (!outDir.exists()) {
|
||||
throw new IOException("cannot create directory " + outDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Path.createDirectorySafe(outDir);
|
||||
writeFile(handler, Utf8Helper.getBytes(domDocumentStr), outDir.getAbsolutePath() + File.separator + "DOMDocument.xml");
|
||||
writeFile(handler, Utf8Helper.getBytes(publishSettingsStr), outDir.getAbsolutePath() + File.separator + "PublishSettings.xml");
|
||||
File libraryDir = new File(outDir.getAbsolutePath() + File.separator + "LIBRARY");
|
||||
@@ -3046,7 +3028,7 @@ public class XFLConverter {
|
||||
if (useAS3) {
|
||||
try {
|
||||
ScriptExportSettings scriptExportSettings = new ScriptExportSettings(ScriptExportMode.AS, false);
|
||||
swf.exportActionScript(handler, outDir.getAbsolutePath(), scriptExportSettings, parallel, null);
|
||||
swf.exportActionScript(handler, Path.combine(outDir.getAbsolutePath(), "scripts"), scriptExportSettings, parallel, null);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, "Error during ActionScript3 export", ex);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2015 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.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.helpers;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -26,15 +28,21 @@ public class Path {
|
||||
public static String combine(String... paths) {
|
||||
String result = "";
|
||||
String separator = File.separator;
|
||||
String separator = File.separator;
|
||||
for (String path : paths) {
|
||||
if (path.startsWith(separator)) {
|
||||
result = result.substring(separator.length());
|
||||
}
|
||||
if (!result.endsWith(separator)) {
|
||||
for (int i = 0; i < paths.length; i++) {
|
||||
String path = paths[i];
|
||||
if (i > 0) {
|
||||
if (path.startsWith(separator)) {
|
||||
path = path.substring(separator.length());
|
||||
}
|
||||
|
||||
if (!result.endsWith(separator)) {
|
||||
result += separator;
|
||||
}
|
||||
}
|
||||
|
||||
result += path;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -69,4 +77,14 @@ public class Path {
|
||||
}
|
||||
return ext;
|
||||
}
|
||||
|
||||
public static void createDirectorySafe(File directory) throws IOException {
|
||||
if (!directory.exists()) {
|
||||
if (!directory.mkdirs()) {
|
||||
if (!directory.exists()) {
|
||||
throw new IOException("Cannot create directory " + directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user