mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-13 15:19:20 +00:00
#978 Class names are case sensitive, but filenames are not, so they are overwritten sometimes during export
This commit is contained in:
@@ -1274,7 +1274,8 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
}
|
||||
String eventData = cnt + scr.getPath() + " ...";
|
||||
evl.handleExportingEvent("tag", i + 1, abcList.size(), eventData);
|
||||
scr.export(outdir, exportSettings, parallel);
|
||||
File file = scr.getExportFile(outdir, exportSettings);
|
||||
scr.export(file, exportSettings, parallel);
|
||||
evl.handleExportedEvent("tag", i + 1, abcList.size(), eventData);
|
||||
exported = true;
|
||||
}
|
||||
|
||||
@@ -107,11 +107,14 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
return scriptName;
|
||||
}
|
||||
|
||||
public File getExportFile(String directory, ScriptExportSettings exportSettings) throws IOException {
|
||||
public File getExportFile(String directory, ScriptExportSettings exportSettings) {
|
||||
if (exportSettings.singleFile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String scriptName = getPathScriptName();
|
||||
DottedChain packageName = getPathPackage();
|
||||
File outDir = new File(directory + File.separatorChar + packageName.toFilePath());
|
||||
Path.createDirectorySafe(outDir);
|
||||
String fileName = outDir.toString() + File.separator + Helper.makeFileName(scriptName) + exportSettings.getFileExtension();
|
||||
return new File(fileName);
|
||||
}
|
||||
@@ -189,16 +192,15 @@ public class ScriptPack extends AS3ClassTreeItem {
|
||||
appendTo(writer, traits, exportMode, parallel);
|
||||
}
|
||||
|
||||
public File export(String directory, ScriptExportSettings exportSettings, boolean parallel) throws IOException, InterruptedException {
|
||||
File file = null;
|
||||
|
||||
public File export(File file, ScriptExportSettings exportSettings, boolean parallel) throws IOException, InterruptedException {
|
||||
if (!exportSettings.singleFile) {
|
||||
file = getExportFile(directory, exportSettings);
|
||||
if (file.exists() && !Configuration.overwriteExistingFiles.get()) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
Path.createDirectorySafe(file.getParentFile());
|
||||
|
||||
try (FileTextWriter writer = exportSettings.singleFile ? null : new FileTextWriter(Configuration.getCodeFormatting(), new FileOutputStream(file))) {
|
||||
FileTextWriter writer2 = exportSettings.singleFile ? exportSettings.singleFileWriter : writer;
|
||||
toSource(writer2, abc.script_info.get(scriptIndex).traits.traits, exportSettings.mode, parallel);
|
||||
|
||||
@@ -24,9 +24,12 @@ import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.settings.ScriptExportSettings;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@@ -51,12 +54,29 @@ public class AS3ScriptExporter {
|
||||
|
||||
int cnt = 1;
|
||||
List<ExportPackTask> tasks = new ArrayList<>();
|
||||
Set<String> files = new HashSet<>();
|
||||
for (ScriptPack item : packs) {
|
||||
if (!item.isSimple && Configuration.ignoreCLikePackages.get()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tasks.add(new ExportPackTask(handler, cnt++, packs.size(), item.getClassPath(), item, outdir, exportSettings, parallel, evl));
|
||||
File file = item.getExportFile(outdir, exportSettings);
|
||||
String filePath = file.getPath();
|
||||
if (files.contains(filePath.toLowerCase())) {
|
||||
String parentPath = file.getParent();
|
||||
String fileName = file.getName();
|
||||
String extension = Path.getExtension(fileName);
|
||||
String fileNameWithoutExtension = Path.getFileNameWithoutExtension(file);
|
||||
int i = 2;
|
||||
do {
|
||||
filePath = Path.combine(parentPath, fileNameWithoutExtension + "_" + i++ + extension);
|
||||
} while (files.contains(filePath.toUpperCase()));
|
||||
|
||||
file = new File(filePath);
|
||||
}
|
||||
|
||||
files.add(filePath.toLowerCase());
|
||||
tasks.add(new ExportPackTask(handler, cnt++, packs.size(), item.getClassPath(), item, file, exportSettings, parallel, evl));
|
||||
}
|
||||
|
||||
if (!parallel || tasks.size() < 2) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ExportPackTask implements Callable<File> {
|
||||
|
||||
ScriptPack pack;
|
||||
|
||||
String directory;
|
||||
File file;
|
||||
|
||||
ScriptExportSettings exportSettings;
|
||||
|
||||
@@ -56,9 +56,9 @@ public class ExportPackTask implements Callable<File> {
|
||||
|
||||
EventListener eventListener;
|
||||
|
||||
public ExportPackTask(AbortRetryIgnoreHandler handler, int index, int count, ClassPath path, ScriptPack pack, String directory, ScriptExportSettings exportSettings, boolean parallel, EventListener evl) {
|
||||
public ExportPackTask(AbortRetryIgnoreHandler handler, int index, int count, ClassPath path, ScriptPack pack, File file, ScriptExportSettings exportSettings, boolean parallel, EventListener evl) {
|
||||
this.pack = pack;
|
||||
this.directory = directory;
|
||||
this.file = file;
|
||||
this.exportSettings = exportSettings;
|
||||
this.path = path;
|
||||
this.index = index;
|
||||
@@ -74,7 +74,7 @@ public class ExportPackTask implements Callable<File> {
|
||||
@Override
|
||||
public void run() throws IOException, InterruptedException {
|
||||
startTime = System.currentTimeMillis();
|
||||
this.result = pack.export(directory, exportSettings, parallel);
|
||||
this.result = pack.export(file, exportSettings, parallel);
|
||||
stopTime = System.currentTimeMillis();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user