From ba44efc73b7eb24d79b2cf050f9b9fd1fe6e77d1 Mon Sep 17 00:00:00 2001 From: benfry Date: Tue, 21 Oct 2008 16:15:24 +0000 Subject: [PATCH] add code to clean java.library.path --- app/src/processing/app/windows/Platform.java | 38 ++++++++++++++++++++ todo.txt | 2 ++ 2 files changed, 40 insertions(+) diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java index 97e5ae93a..2e5729272 100644 --- a/app/src/processing/app/windows/Platform.java +++ b/app/src/processing/app/windows/Platform.java @@ -24,10 +24,12 @@ package processing.app.windows; import java.io.File; import java.io.UnsupportedEncodingException; +import java.util.ArrayList; import processing.app.Base; import processing.app.Preferences; import processing.app.windows.Registry.REGISTRY_ROOT_KEY; +import processing.core.PApplet; // http://developer.apple.com/documentation/QuickTime/Conceptual/QT7Win_Update_Guide/Chapter03/chapter_3_section_1.html @@ -48,6 +50,7 @@ public class Platform extends processing.app.Platform { checkAssociations(); checkQuickTime(); + checkPath(); } @@ -131,6 +134,41 @@ public class Platform extends processing.app.Platform { e.printStackTrace(); } } + + + /** + * Remove extra quotes, slashes, and garbage from the Windows PATH. + */ + protected void checkPath() { + String path = System.getProperty("java.library.path"); + String[] pieces = PApplet.split(path, File.pathSeparatorChar); + String[] legit = new String[pieces.length]; + int legitCount = 0; + for (String item : pieces) { + if (item.startsWith("\"")) { + item = item.substring(1); + } + if (item.endsWith("\"")) { + item = item.substring(0, item.length() - 1); + } + if (item.endsWith(File.separator)) { + item = item.substring(0, item.length() - File.separator.length()); + } + File directory = new File(item); + if (!directory.exists()) { + continue; + } + if (item.trim().length() == 0) { + continue; + } + legit[legitCount++] = item; + } + legit = PApplet.subset(legit, 0, legitCount); + String newPath = PApplet.join(legit, File.pathSeparator); + if (!newPath.equals(path)) { + System.setProperty("java.library.path", newPath); + } + } // looking for Documents and Settings/blah/Application Data/Processing diff --git a/todo.txt b/todo.txt index bcbc493e8..1ba9b0323 100644 --- a/todo.txt +++ b/todo.txt @@ -1,5 +1,7 @@ 0154 pde +_ clean up PATH for users who have garbage in the PATH +_ http://dev.processing.org/bugs/show_bug.cgi?id=974 _ don't open more than one "create font" or "color selector" _ http://dev.processing.org/bugs/show_bug.cgi?id=830