mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-06 15:59:10 +00:00
windows+mac "exe" export with adobe projector
This commit is contained in:
@@ -795,14 +795,18 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
}
|
||||
os.write(data);
|
||||
} else if (compression == SWFCompression.ZLIB) {
|
||||
try (DeflaterOutputStream dos = new DeflaterOutputStream(os)) {
|
||||
Helper.copyStream(is, dos, Long.MAX_VALUE);
|
||||
DeflaterOutputStream dos = new DeflaterOutputStream(os);
|
||||
try {
|
||||
Helper.copyStream(is, dos);
|
||||
} finally {
|
||||
dos.finish();
|
||||
}
|
||||
} else {
|
||||
Helper.copyStream(is, os, Long.MAX_VALUE);
|
||||
Helper.copyStream(is, os);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
for (Tag tag : tags) {
|
||||
if (tag.isModified()) {
|
||||
|
||||
@@ -879,26 +879,56 @@ public class Configuration {
|
||||
}
|
||||
|
||||
public static File getPlayerSWC() {
|
||||
String a = getLatestPlayerGlobalUrl();
|
||||
String b = getLatestProjectorUrlWin();
|
||||
String c = getLatestProjectorUrlMac();
|
||||
String d = getLatestProjectorUrlLinux();
|
||||
File libsdir = getFlashLibPath();
|
||||
if (libsdir != null && libsdir.exists()) {
|
||||
File[] libs = libsdir.listFiles(new FilenameFilter() {
|
||||
File libsDir = getFlashLibPath();
|
||||
if (libsDir != null && libsDir.exists()) {
|
||||
File[] libs = libsDir.listFiles(new FilenameFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.toLowerCase().startsWith("playerglobal");
|
||||
}
|
||||
});
|
||||
List<String> libnames = new ArrayList<>();
|
||||
List<String> libNames = new ArrayList<>();
|
||||
for (File f : libs) {
|
||||
libnames.add(f.getName());
|
||||
libNames.add(f.getName());
|
||||
}
|
||||
Collections.sort(libnames);
|
||||
if (!libnames.isEmpty()) {
|
||||
return new File(libsdir.getAbsolutePath() + File.separator + libnames.get(libnames.size() - 1));
|
||||
Collections.sort(libNames);
|
||||
if (!libNames.isEmpty()) {
|
||||
return new File(libsDir.getAbsolutePath() + File.separator + libNames.get(libNames.size() - 1));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static File getProjectorFile(ExeExportMode exportMode) {
|
||||
File projectoDir = getProjectorPath();
|
||||
if (projectoDir != null && projectoDir.exists()) {
|
||||
File[] projectors = projectoDir.listFiles(new FilenameFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
switch (exportMode) {
|
||||
case PROJECTOR_WIN:
|
||||
return name.toLowerCase().endsWith(".exe");
|
||||
case PROJECTOR_MAC:
|
||||
return name.toLowerCase().endsWith(".dmg");
|
||||
case PROJECTOR_LINUX:
|
||||
return name.toLowerCase().endsWith(".gz");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
List<String> projectorNames = new ArrayList<>();
|
||||
for (File f : projectors) {
|
||||
projectorNames.add(f.getName());
|
||||
}
|
||||
Collections.sort(projectorNames);
|
||||
if (!projectorNames.isEmpty()) {
|
||||
return new File(projectoDir.getAbsolutePath() + File.separator + projectorNames.get(projectorNames.size() - 1));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,5 @@ package com.jpexs.decompiler.flash.exporters.modes;
|
||||
*/
|
||||
public enum ExeExportMode {
|
||||
|
||||
WRAPPER, PROJECTOR_WIN, PROJECTOR_MAC/*, PROJECTOR_LINUX*/
|
||||
|
||||
WRAPPER, PROJECTOR_WIN, PROJECTOR_MAC, PROJECTOR_LINUX
|
||||
}
|
||||
|
||||
@@ -655,6 +655,19 @@ public class Helper {
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
public static void copyStream(InputStream is, OutputStream os) {
|
||||
try {
|
||||
final int bufSize = 4096;
|
||||
byte[] buf = new byte[bufSize];
|
||||
int cnt = 0;
|
||||
while ((cnt = is.read(buf)) > 0) {
|
||||
os.write(buf, 0, cnt);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyStream(InputStream is, OutputStream os, long maxLength) {
|
||||
try {
|
||||
final int bufSize = 4096;
|
||||
|
||||
@@ -67,7 +67,6 @@ import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
@@ -392,37 +391,63 @@ public class Main {
|
||||
}
|
||||
File outfileF = new File(outfile);
|
||||
File tmpFile = new File(outfile + ".tmp");
|
||||
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(tmpFile))) {
|
||||
try (FileOutputStream fos = new FileOutputStream(tmpFile);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(fos)) {
|
||||
if (mode == SaveFileMode.EXE) {
|
||||
switch (exeExportMode) {
|
||||
case WRAPPER:
|
||||
InputStream exeStream = View.class.getClassLoader().getResourceAsStream("com/jpexs/helpers/resource/Swf2Exe.bin");
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = exeStream.read(buffer)) != -1) {
|
||||
fos.write(buffer, 0, bytesRead);
|
||||
}
|
||||
Helper.copyStream(exeStream, bos);
|
||||
int width = swf.displayRect.Xmax - swf.displayRect.Xmin;
|
||||
int height = swf.displayRect.Ymax - swf.displayRect.Ymin;
|
||||
fos.write(width & 0xff);
|
||||
fos.write((width >> 8) & 0xff);
|
||||
fos.write((width >> 16) & 0xff);
|
||||
fos.write((width >> 24) & 0xff);
|
||||
fos.write(height & 0xff);
|
||||
fos.write((height >> 8) & 0xff);
|
||||
fos.write((height >> 16) & 0xff);
|
||||
fos.write((height >> 24) & 0xff);
|
||||
fos.write(Configuration.saveAsExeScaleMode.get());
|
||||
bos.write(width & 0xff);
|
||||
bos.write((width >> 8) & 0xff);
|
||||
bos.write((width >> 16) & 0xff);
|
||||
bos.write((width >> 24) & 0xff);
|
||||
bos.write(height & 0xff);
|
||||
bos.write((height >> 8) & 0xff);
|
||||
bos.write((height >> 16) & 0xff);
|
||||
bos.write((height >> 24) & 0xff);
|
||||
bos.write(Configuration.saveAsExeScaleMode.get());
|
||||
break;
|
||||
case PROJECTOR_WIN:
|
||||
// todo
|
||||
break;
|
||||
case PROJECTOR_MAC:
|
||||
// todo
|
||||
case PROJECTOR_LINUX:
|
||||
File projectorFile = Configuration.getProjectorFile(exeExportMode);
|
||||
if (projectorFile == null) {
|
||||
String message = "Projector not found, please place it to " + Configuration.getProjectorPath();
|
||||
logger.log(Level.SEVERE, message);
|
||||
throw new IOException(message);
|
||||
}
|
||||
Helper.copyStream(new FileInputStream(projectorFile), bos);
|
||||
bos.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
swf.saveTo(fos);
|
||||
|
||||
long pos = fos.getChannel().position();
|
||||
swf.saveTo(bos);
|
||||
|
||||
if (mode == SaveFileMode.EXE) {
|
||||
switch (exeExportMode) {
|
||||
case PROJECTOR_WIN:
|
||||
case PROJECTOR_MAC:
|
||||
case PROJECTOR_LINUX:
|
||||
bos.flush();
|
||||
int swfSize = (int) (fos.getChannel().position() - pos);
|
||||
|
||||
// write magic number
|
||||
bos.write(0x56);
|
||||
bos.write(0x34);
|
||||
bos.write(0x12);
|
||||
bos.write(0xfa);
|
||||
|
||||
bos.write(swfSize & 0xff);
|
||||
bos.write((swfSize >> 8) & 0xff);
|
||||
bos.write((swfSize >> 16) & 0xff);
|
||||
bos.write((swfSize >> 24) & 0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tmpFile.exists()) {
|
||||
if (tmpFile.length() > 0) {
|
||||
|
||||
Reference in New Issue
Block a user