diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java old mode 100644 new mode 100755 diff --git a/app/src/processing/app/Util.java b/app/src/processing/app/Util.java old mode 100644 new mode 100755 index 4dd579781..fad04cec5 --- a/app/src/processing/app/Util.java +++ b/app/src/processing/app/Util.java @@ -666,4 +666,12 @@ public class Util { output.close(); return baos.toByteArray(); } + + + static public final boolean hasNonAsciiChars(String what) { + for (char c : what.toCharArray()) { + if (c < 32 || c > 127) return true; + } + return false; + } } diff --git a/app/src/processing/app/platform/WindowsPlatform.java b/app/src/processing/app/platform/WindowsPlatform.java old mode 100644 new mode 100755 index 0eb31ddd4..12d1da284 --- a/app/src/processing/app/platform/WindowsPlatform.java +++ b/app/src/processing/app/platform/WindowsPlatform.java @@ -34,6 +34,7 @@ import com.sun.jna.platform.win32.ShlObj; import processing.app.Base; import processing.app.Messages; import processing.app.Preferences; +import processing.app.Util; import processing.app.platform.WindowsRegistry.REGISTRY_ROOT_KEY; import processing.core.PApplet; @@ -255,29 +256,43 @@ public class WindowsPlatform extends DefaultPlatform { // looking for Documents and Settings/blah/Application Data/Processing public File getSettingsFolder() throws Exception { - String appDataRoaming = getAppDataPath(); - if (appDataRoaming != null) { - File settingsFolder = new File(appDataRoaming, APP_NAME); - if (settingsFolder.exists() || settingsFolder.mkdirs()) { - return settingsFolder; + try { + String appDataRoaming = getAppDataPath(); + if (appDataRoaming != null) { + File settingsFolder = new File(appDataRoaming, APP_NAME); + if (settingsFolder.exists() || settingsFolder.mkdirs()) { + return settingsFolder; + } } - } - String appDataLocal = getLocalAppDataPath(); - if (appDataLocal != null) { - File settingsFolder = new File(appDataLocal, APP_NAME); - if (settingsFolder.exists() || settingsFolder.mkdirs()) { - return settingsFolder; + String appDataLocal = getLocalAppDataPath(); + if (appDataLocal != null) { + File settingsFolder = new File(appDataLocal, APP_NAME); + if (settingsFolder.exists() || settingsFolder.mkdirs()) { + return settingsFolder; + } } - } - if (appDataRoaming == null && appDataLocal == null) { - throw new IOException("Could not get the AppData folder"); - } + if (appDataRoaming == null && appDataLocal == null) { + throw new IOException("Could not get the AppData folder"); + } - // https://github.com/processing/processing/issues/3838 - throw new IOException("Please fix permissions for either " + - appDataRoaming + " or " + appDataLocal); + // https://github.com/processing/processing/issues/3838 + throw new IOException("Permissions error: make sure that " + + appDataRoaming + " or " + appDataLocal + + " is writable."); + + } catch (UnsatisfiedLinkError ule) { + String path = new File("lib").getCanonicalPath(); + + String msg = Util.hasNonAsciiChars(path) ? + "Please move Processing to a location with only\n" + + "ASCII characters in the path and try again.\n" + + "https://github.com/processing/processing/issues/3543" : + "Could not find JNA support files, please reinstall Processing."; + Messages.showError("Windows JNA Problem", msg, ule); + return null; // unreachable + } } diff --git a/app/src/processing/app/ui/Toolkit.java b/app/src/processing/app/ui/Toolkit.java old mode 100644 new mode 100755 index 483716a2b..fc515eb5a --- a/app/src/processing/app/ui/Toolkit.java +++ b/app/src/processing/app/ui/Toolkit.java @@ -72,6 +72,7 @@ import processing.app.Language; import processing.app.Messages; import processing.app.Platform; import processing.app.Preferences; +import processing.app.Util; /** @@ -990,7 +991,7 @@ public class Toolkit { // This gets the JAVA_HOME for the *local* copy of the JRE installed with // Processing. If it's not using the local JRE, it may be because of this // launch4j bug: https://github.com/processing/processing/issues/3543 - if (hasNonAsciiChars(Platform.getJavaHome().getAbsolutePath())) { + if (Util.hasNonAsciiChars(Platform.getJavaHome().getAbsolutePath())) { msg += "Trying moving Processing\n" + "to a location with only ASCII characters in the path."; } else { @@ -1006,14 +1007,6 @@ public class Toolkit { } - static private final boolean hasNonAsciiChars(String what) { - for (char c : what.toCharArray()) { - if (c < 32 || c > 127) return true; - } - return false; - } - - /** * Synthesized replacement for FontMetrics.getAscent(), which is dreadfully * inaccurate and inconsistent across platforms.