Skip to content

Commit

Permalink
Fixed FLA export scripts location
Browse files Browse the repository at this point in the history
  • Loading branch information
jindrapetrik committed Mar 19, 2023
1 parent fe41355 commit ed57d71
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ All notable changes to this project will be documented in this file.
- [#1990] Cloning DefineSprite causing incorrect tags written
- Do not display fonts added to stage (for example in testdata/as2.swf, the vertical text - sprite 10)
- AS2 Class detection - TemporaryRegisterMark handling
- FLA export scripts location

### Changed
- AS1/2/3 P-code - format Number values with EcmaScript toString function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3552,22 +3552,26 @@ public void convertSWF(AbortRetryIgnoreHandler handler, SWF swf, String swfFileN
if (!useAS3 && flaVersion.minASVersion() > 2) {
throw new IllegalArgumentException("FLA version " + flaVersion + " does not support AS1/2");
}
File file = new File(outfile);
File flaFile = new File(outfile); //c:/mydir/myfile.fla
String baseName = swfFileName;
File f = new File(baseName);
File f = new File(baseName); //myfile.swf
baseName = f.getName();
if (baseName.contains(".")) {
baseName = baseName.substring(0, baseName.lastIndexOf('.'));
baseName = baseName.substring(0, baseName.lastIndexOf('.')); //myfile
}

File outDir = file.getParentFile();
File scriptsDir = flaFile.getParentFile(); //c:/mydir

Path.createDirectorySafe(scriptsDir);

File xflDataDir = null;
String xflFile = null;
if (!settings.compressed) {
outDir = new File(Path.combine(outDir.getAbsolutePath(), baseName));
outfile = Path.combine(outDir.getAbsolutePath(), baseName + ".xfl");
file = new File(outfile);
xflDataDir = new File(Path.combine(flaFile.getParentFile().getAbsolutePath(), baseName)); //c:/mydir/myfile/
xflFile = Path.combine(xflDataDir.getAbsolutePath(), baseName + ".xfl"); // c:/mydir/myfile.xfl
Path.createDirectorySafe(xflDataDir);
}

Path.createDirectorySafe(outDir);


final HashMap<String, byte[]> files = new HashMap<>();
Expand Down Expand Up @@ -3667,9 +3671,9 @@ public void convertSWF(AbortRetryIgnoreHandler handler, SWF swf, String swfFileN
expDir = expDir.replace(".", File.separator);
}
expPath = expPath.replace(".", File.separator);
File cdir = new File(outDir.getAbsolutePath() + File.separator + expDir);
File cdir = new File(scriptsDir.getAbsolutePath() + File.separator + expDir);
Path.createDirectorySafe(cdir);
writeFile(handler, Utf8Helper.getBytes(data), outDir.getAbsolutePath() + File.separator + expPath + ".as");
writeFile(handler, Utf8Helper.getBytes(data), scriptsDir.getAbsolutePath() + File.separator + expPath + ".as");
}
}
}
Expand Down Expand Up @@ -3948,25 +3952,25 @@ public void convertSWF(AbortRetryIgnoreHandler handler, SWF swf, String swfFileN
}, handler).run();

} else {
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");
Path.createDirectorySafe(xflDataDir);
writeFile(handler, Utf8Helper.getBytes(domDocumentStr), xflDataDir.getAbsolutePath() + File.separator + "DOMDocument.xml");
writeFile(handler, Utf8Helper.getBytes(publishSettingsStr), xflDataDir.getAbsolutePath() + File.separator + "PublishSettings.xml");
File libraryDir = new File(xflDataDir.getAbsolutePath() + File.separator + "LIBRARY");
libraryDir.mkdir();
File binDir = new File(outDir.getAbsolutePath() + File.separator + "bin");
File binDir = new File(xflDataDir.getAbsolutePath() + File.separator + "bin");
binDir.mkdir();
for (String fileName : files.keySet()) {
writeFile(handler, files.get(fileName), libraryDir.getAbsolutePath() + File.separator + fileName);
}
for (String fileName : datfiles.keySet()) {
writeFile(handler, datfiles.get(fileName), binDir.getAbsolutePath() + File.separator + fileName);
}
writeFile(handler, Utf8Helper.getBytes("PROXY-CS5"), outfile);
writeFile(handler, Utf8Helper.getBytes("PROXY-CS5"), xflFile);
}
if (useAS3 && settings.exportScript) {
try {
ScriptExportSettings scriptExportSettings = new ScriptExportSettings(ScriptExportMode.AS, false, true);
swf.exportActionScript(handler, outDir.getAbsolutePath(), scriptExportSettings, parallel, null);
swf.exportActionScript(handler, scriptsDir.getAbsolutePath(), scriptExportSettings, parallel, null);
} catch (Exception ex) {
logger.log(Level.SEVERE, "Error during ActionScript3 export", ex);
}
Expand Down

0 comments on commit ed57d71

Please sign in to comment.