Merge pull request #156 from cyian-1756/portable

Added portable mode
This commit is contained in:
cyian-1756 2017-11-10 03:45:48 -05:00 committed by GitHub
commit d70df6e9be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -164,7 +164,28 @@ public class Utils {
+ File.separator + "Library" + File.separator + "Application Support" + File.separator + "ripme"; + File.separator + "Library" + File.separator + "Application Support" + File.separator + "ripme";
} }
private static boolean portableMode() {
try {
File f = new File(new File(".").getCanonicalPath() + File.separator + configFile);
if(f.exists() && !f.isDirectory()) {
return true;
}
} catch (IOException e) {
return false;
}
return false;
}
public static String getConfigDir() { public static String getConfigDir() {
if (portableMode()) {
try {
return new File(".").getCanonicalPath();
} catch (Exception e) {
return ".";
}
}
if (isWindows()) return getWindowsConfigDir(); if (isWindows()) return getWindowsConfigDir();
if (isMacOS()) return getMacOSConfigDir(); if (isMacOS()) return getMacOSConfigDir();
if (isUnix()) return getUnixConfigDir(); if (isUnix()) return getUnixConfigDir();