From 7e86723b2e1c3ed754a85fd085460e00d5b7dcdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Thu, 28 Sep 2023 19:11:51 +0200 Subject: [PATCH] Removing some deprecated things --- .../flash/configuration/Configuration.java | 27 +++++++------------ .../flash/gui/graph/GraphVizDotCommands.java | 14 ++++++---- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 3a66af938..a817552fb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -34,8 +34,6 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.lang.reflect.Field; import java.net.URISyntaxException; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; @@ -44,6 +42,7 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.logging.Level; @@ -923,23 +922,15 @@ public final class Configuration { WINDOWS, OSX, UNIX } - private static OSId getOSId() { - PrivilegedAction doGetOSName = new PrivilegedAction() { - @Override - public String run() { - return System.getProperty("os.name"); - } - }; - OSId id = OSId.UNIX; - String osName = AccessController.doPrivileged(doGetOSName); - if (osName != null) { - if (osName.toLowerCase().startsWith("mac os x")) { - id = OSId.OSX; - } else if (osName.contains("Windows")) { - id = OSId.WINDOWS; - } + private static OSId getOSId() { + String OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH); + if ((OS.indexOf("mac") >= 0) || (OS.indexOf("darwin") >= 0)) { + return OSId.OSX; + } else if (OS.indexOf("win") >= 0) { + return OSId.WINDOWS; + } else { + return OSId.UNIX; } - return id; } public static String getFFDecHome() { diff --git a/src/com/jpexs/decompiler/flash/gui/graph/GraphVizDotCommands.java b/src/com/jpexs/decompiler/flash/gui/graph/GraphVizDotCommands.java index 1c240b7d3..75e3bcd4f 100644 --- a/src/com/jpexs/decompiler/flash/gui/graph/GraphVizDotCommands.java +++ b/src/com/jpexs/decompiler/flash/gui/graph/GraphVizDotCommands.java @@ -39,7 +39,7 @@ public class GraphVizDotCommands { return true; } - private static void runCommand(String command) { + private static void runCommand(String[] command) { try { Process process = Runtime.getRuntime().exec(command); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); @@ -52,12 +52,17 @@ public class GraphVizDotCommands { } } - private static boolean runDotCommand(String command) { + private static boolean runDotCommand(String[] command) { String dotLocation = Configuration.graphVizDotLocation.get(); if (dotLocation.isEmpty() && !new File(dotLocation).exists()) { return false; }// - runCommand("\"" + dotLocation + "\" " + command); + String[] commandPlusDot = new String[command.length + 1]; + commandPlusDot[0] = dotLocation; + for (int i = 0; i < command.length; i++) { + commandPlusDot[1 + i] = command[i]; + } + runCommand(commandPlusDot); return true; } @@ -68,8 +73,7 @@ public class GraphVizDotCommands { PrintWriter pw = new PrintWriter(gvFile); pw.println(text); pw.close(); - String extraParams = " -Nfontname=times-bold -Nfontsize=12"; - if (!runDotCommand("-Tpng" + extraParams + " -o \"" + pngFile.getAbsolutePath() + "\" \"" + gvFile.getAbsolutePath() + "\"")) { + if (!runDotCommand(new String[]{"-Tpng", "-Nfontname=times-bold", "-Nfontsize=12", "-o", pngFile.getAbsolutePath(), gvFile.getAbsolutePath()})) { gvFile.delete(); return null; }