|
@@ -380,33 +380,43 @@ public final class Main {
|
380
|
380
|
*/
|
381
|
381
|
public static String getConfigDir() {
|
382
|
382
|
if (configdir == null) {
|
383
|
|
- final String fs = System.getProperty("file.separator");
|
384
|
|
- final String osName = System.getProperty("os.name");
|
385
|
|
- if (osName.startsWith("Mac OS")) {
|
386
|
|
- configdir = System.getProperty("user.home") + fs + "Library"
|
387
|
|
- + fs + "Preferences" + fs + "DMDirc" + fs;
|
388
|
|
- } else if (osName.startsWith("Windows")) {
|
389
|
|
- if (System.getenv("APPDATA") == null) {
|
390
|
|
- configdir = System.getProperty("user.home") + fs + "DMDirc" + fs;
|
391
|
|
- } else {
|
392
|
|
- configdir = System.getenv("APPDATA") + fs + "DMDirc" + fs;
|
393
|
|
- }
|
|
383
|
+ initialiseConfigDir();
|
|
384
|
+ }
|
|
385
|
+
|
|
386
|
+ return configdir;
|
|
387
|
+ }
|
|
388
|
+
|
|
389
|
+ /**
|
|
390
|
+ * Initialises the location of the configuration directory.
|
|
391
|
+ */
|
|
392
|
+ protected static void initialiseConfigDir() {
|
|
393
|
+ final String fs = System.getProperty("file.separator");
|
|
394
|
+ final String osName = System.getProperty("os.name");
|
|
395
|
+
|
|
396
|
+ if (System.getenv("DMDIRC_HOME") != null) {
|
|
397
|
+ configdir = System.getenv("DMDIRC_HOME");
|
|
398
|
+ } else if (osName.startsWith("Mac OS")) {
|
|
399
|
+ configdir = System.getProperty("user.home") + fs + "Library"
|
|
400
|
+ + fs + "Preferences" + fs + "DMDirc" + fs;
|
|
401
|
+ } else if (osName.startsWith("Windows")) {
|
|
402
|
+ if (System.getenv("APPDATA") == null) {
|
|
403
|
+ configdir = System.getProperty("user.home") + fs + "DMDirc" + fs;
|
394
|
404
|
} else {
|
395
|
|
- configdir = System.getProperty("user.home") + fs + ".DMDirc" + fs;
|
396
|
|
- final File testFile = new File(configdir);
|
397
|
|
- if (!testFile.exists()) {
|
398
|
|
- final String configHome = System.getenv("XDG_CONFIG_HOME");
|
399
|
|
- configdir = (configHome == null || configHome.isEmpty()) ?
|
400
|
|
- System.getProperty("user.home") + fs + ".config" + fs :
|
401
|
|
- configHome;
|
402
|
|
- configdir += fs + "DMDirc" + fs;
|
403
|
|
- }
|
|
405
|
+ configdir = System.getenv("APPDATA") + fs + "DMDirc" + fs;
|
|
406
|
+ }
|
|
407
|
+ } else {
|
|
408
|
+ configdir = System.getProperty("user.home") + fs + ".DMDirc" + fs;
|
|
409
|
+ final File testFile = new File(configdir);
|
|
410
|
+ if (!testFile.exists()) {
|
|
411
|
+ final String configHome = System.getenv("XDG_CONFIG_HOME");
|
|
412
|
+ configdir = (configHome == null || configHome.isEmpty()) ?
|
|
413
|
+ System.getProperty("user.home") + fs + ".config" + fs :
|
|
414
|
+ configHome;
|
|
415
|
+ configdir += fs + "DMDirc" + fs;
|
404
|
416
|
}
|
405
|
|
-
|
406
|
|
- configdir = new File(configdir).getAbsolutePath() + fs;
|
407
|
417
|
}
|
408
|
418
|
|
409
|
|
- return configdir;
|
|
419
|
+ configdir = new File(configdir).getAbsolutePath() + fs;
|
410
|
420
|
}
|
411
|
421
|
|
412
|
422
|
/**
|