add code to clean java.library.path

This commit is contained in:
benfry
2008-10-21 16:15:24 +00:00
parent e2361ac4ce
commit ba44efc73b
2 changed files with 40 additions and 0 deletions

View File

@@ -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

View File

@@ -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