Add support for XDG base directory specification

This commit is contained in:
keremgokcek
2024-07-31 03:37:33 +03:00
committed by Jindra Petřík
parent 2336515b17
commit 89d7a47453

View File

@@ -1061,9 +1061,24 @@ public final class Configuration {
String path = "Library/Application Support/" + applicationId + "/";
directory = new File(userHome, path);
} else {
// ${userHome}/.${applicationId}/
String path = "." + applicationId + "/";
directory = new File(userHome, path);
File xdgConfigHome = null;
try {
String xdgConfigHomeEV = System.getenv("XDG_CONFIG_HOME");
if ((xdgConfigHomeEV != null) && (xdgConfigHomeEV.length() > 0)) {
xdgConfigHome = new File(xdgConfigHomeEV);
}
} catch (SecurityException ignore) {
//ignored
}
if ((xdgConfigHome != null) && xdgConfigHome.isDirectory()) {
// ${xdgConfigHome}/${applicationId}
String path = applicationId + "/";
directory = new File(xdgConfigHome, path);
} else {
// ${userHome}/.config/${applicationId}
String path = ".config/" + applicationId + "/";
directory = new File(userHome, path);
}
}
} else {
//no home, then use application directory