Hopefully a more robust way to get the user data dir on Windows, especially on Windows Vista 64-bit, which jdatapath.dll isn't built for.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@311 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
e1d064f25c
commit
b26160dc2b
@ -53,6 +53,7 @@ public class ProjectManager {
|
||||
|
||||
String os = Configurations.get("os.name").toLowerCase();
|
||||
if (os.contains("windows")) {
|
||||
try {
|
||||
// NOTE(SM): finding the "local data app" in windows from java is actually a PITA
|
||||
// see http://stackoverflow.com/questions/1198911/how-to-get-local-application-data-folder-in-java
|
||||
// so we're using a library that uses JNI to ask directly the win32 APIs,
|
||||
@ -61,6 +62,29 @@ public class ProjectManager {
|
||||
File data = new File(localDataPath.getPath());
|
||||
data.mkdirs();
|
||||
return data;
|
||||
} catch (Error e) {
|
||||
Gridworks.log("Failed to use jdatapath to detect user data path. Resorting to environment variables.");
|
||||
|
||||
String appData = System.getenv("APPDATA");
|
||||
File parentDir = null;
|
||||
if (appData != null && appData.length() > 0) {
|
||||
parentDir = new File(appData);
|
||||
} else {
|
||||
String userProfile = System.getenv("USERPROFILE");
|
||||
if (userProfile != null && userProfile.length() > 0) {
|
||||
parentDir = new File(userProfile);
|
||||
}
|
||||
}
|
||||
|
||||
if (parentDir == null) {
|
||||
parentDir = new File(".");
|
||||
}
|
||||
|
||||
File data = new File(parentDir, "Gridworks");
|
||||
data.mkdirs();
|
||||
|
||||
return data;
|
||||
}
|
||||
} else if (os.contains("mac os x")) {
|
||||
// on macosx, use "~/Library/Application Support"
|
||||
String home = System.getProperty("user.home");
|
||||
|
Loading…
Reference in New Issue
Block a user