If refine data dir doesn't exist, try to find and move gridworks data dir over
git-svn-id: http://google-refine.googlecode.com/svn/trunk@1294 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
d15fe661fa
commit
b45506b787
@ -254,12 +254,13 @@ class RefineServer extends Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static private String getDataDir() {
|
static private String getDataDir() {
|
||||||
|
|
||||||
String data_dir = Configurations.get("refine.data_dir");
|
String data_dir = Configurations.get("refine.data_dir");
|
||||||
if (data_dir != null) {
|
if (data_dir != null) {
|
||||||
return data_dir;
|
return data_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File dataDir = null;
|
||||||
|
|
||||||
String os = System.getProperty("os.name").toLowerCase();
|
String os = System.getProperty("os.name").toLowerCase();
|
||||||
if (os.contains("windows")) {
|
if (os.contains("windows")) {
|
||||||
try {
|
try {
|
||||||
@ -268,10 +269,10 @@ class RefineServer extends Server {
|
|||||||
// so we're using a library that uses JNI to ask directly the win32 APIs,
|
// so we're using a library that uses JNI to ask directly the win32 APIs,
|
||||||
// it's not elegant but it's the safest bet.
|
// it's not elegant but it's the safest bet.
|
||||||
|
|
||||||
DataPath localDataPath = JDataPathSystem.getLocalSystem().getLocalDataPath("Gridworks");
|
DataPath localDataPath = JDataPathSystem.getLocalSystem().getLocalDataPath("Google");
|
||||||
File data = new File(fixWindowsUnicodePath(localDataPath.getPath()));
|
|
||||||
data.mkdirs();
|
dataDir = new File(new File(fixWindowsUnicodePath(localDataPath.getPath())), "Refine");
|
||||||
return data.getAbsolutePath();
|
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
/*
|
/*
|
||||||
* The above trick can fail, particularly on a 64-bit OS as the jdatapath.dll
|
* The above trick can fail, particularly on a 64-bit OS as the jdatapath.dll
|
||||||
@ -298,18 +299,15 @@ class RefineServer extends Server {
|
|||||||
parentDir = new File(".");
|
parentDir = new File(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
File data = new File(parentDir, "Gridworks");
|
dataDir = new File(new File(parentDir, "Google"), "Refine");
|
||||||
data.mkdirs();
|
|
||||||
|
|
||||||
return data.getAbsolutePath();
|
|
||||||
}
|
}
|
||||||
} else if (os.contains("mac os x")) {
|
} else if (os.contains("mac os x")) {
|
||||||
// on macosx, use "~/Library/Application Support"
|
// on macosx, use "~/Library/Application Support"
|
||||||
String home = System.getProperty("user.home");
|
String home = System.getProperty("user.home");
|
||||||
String data_home = (home != null) ? home + "/Library/Application Support/Gridworks" : ".gridworks";
|
String data_home = (home != null) ? home + "/Library/Application Support/Google/Refine" : ".google-refine";
|
||||||
File data = new File(data_home);
|
|
||||||
data.mkdirs();
|
dataDir = new File(data_home);
|
||||||
return data.getAbsolutePath();
|
|
||||||
} else { // most likely a UNIX flavor
|
} else { // most likely a UNIX flavor
|
||||||
// start with the XDG environment
|
// start with the XDG environment
|
||||||
// see http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
// see http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||||
@ -319,10 +317,29 @@ class RefineServer extends Server {
|
|||||||
if (home == null) home = ".";
|
if (home == null) home = ".";
|
||||||
data_home = home + "/.local/share";
|
data_home = home + "/.local/share";
|
||||||
}
|
}
|
||||||
File data = new File(data_home + "/gridworks");
|
|
||||||
data.mkdirs();
|
dataDir = new File(data_home + "/google-refine");
|
||||||
return data.getAbsolutePath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If refine data dir doesn't exist, try to find and move gridworks data dir over
|
||||||
|
if (!dataDir.exists()) {
|
||||||
|
File gridworksDir;
|
||||||
|
if (dataDir.getName().equals("Refine")) {
|
||||||
|
gridworksDir = new File(dataDir.getParentFile().getParentFile(), "Gridworks");
|
||||||
|
} else if (dataDir.getName().startsWith(".")) {
|
||||||
|
gridworksDir = new File(dataDir.getParent(), ".gridworks");
|
||||||
|
} else {
|
||||||
|
gridworksDir = new File(dataDir.getParent(), ".gridworks");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gridworksDir.exists()) {
|
||||||
|
gridworksDir.renameTo(dataDir);
|
||||||
|
} else {
|
||||||
|
dataDir.mkdirs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataDir.getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user