- Timestamp:
- 2016-10-25T19:05:35+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r11161 r11162 295 295 296 296 /** 297 * Get the base name of the JOSM directories for preferences, cache and 298 * user data. 299 * Default value is "JOSM", unless overridden by system property "josm.dir.name". 300 * @return the base name of the JOSM directories for preferences, cache and 301 * user data 302 */ 303 public String getJOSMDirectoryBaseName() { 304 String name = System.getProperty("josm.dir.name"); 305 if (name != null) 306 return name; 307 else 308 return "JOSM"; 309 } 310 311 /** 297 312 * Returns the user defined preferences directory, containing the preferences.xml file 298 313 * @return The user defined preferences directory, containing the preferences.xml file -
trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r11156 r11162 366 366 @Override 367 367 public File getDefaultCacheDirectory() { 368 return new File(System.getProperty("user.home")+"/Library/Caches", "JOSM"); 368 return new File(System.getProperty("user.home")+"/Library/Caches", 369 Main.pref.getJOSMDirectoryBaseName()); 369 370 } 370 371 371 372 @Override 372 373 public File getDefaultPrefDirectory() { 373 return new File(System.getProperty("user.home")+"/Library/Preferences", "JOSM"); 374 return new File(System.getProperty("user.home")+"/Library/Preferences", 375 Main.pref.getJOSMDirectoryBaseName()); 374 376 } 375 377 376 378 @Override 377 379 public File getDefaultUserDataDirectory() { 378 return new File(System.getProperty("user.home")+"/Library", "JOSM"); 380 return new File(System.getProperty("user.home")+"/Library", 381 Main.pref.getJOSMDirectoryBaseName()); 379 382 } 380 383 } -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r11156 r11162 18 18 import java.nio.file.Paths; 19 19 import java.util.Arrays; 20 import java.util.Locale; 20 21 21 22 import javax.swing.JOptionPane; … … 368 369 } 369 370 371 /** 372 * Get the dot directory <code>~/.josm</code>. 373 * @return the dot directory 374 */ 375 private File getDotDirectory() { 376 String dirName = "." + Main.pref.getJOSMDirectoryBaseName().toLowerCase(Locale.ENGLISH); 377 return new File(System.getProperty("user.home"), dirName); 378 } 379 380 /** 381 * Returns true if the dot directory should be used for storing preferences, 382 * cache and user data. 383 * Currently this is the case, if the dot directory already exists. 384 * @return true if the dot directory should be used 385 */ 386 private boolean useDotDirectory() { 387 return getDotDirectory().exists(); 388 } 389 370 390 @Override 371 391 public File getDefaultCacheDirectory() { 372 return new File(Main.pref.getUserDataDirectory(), "cache"); 392 if (useDotDirectory()) { 393 return new File(getDotDirectory(), "cache"); 394 } else { 395 String xdgCacheDir = System.getenv("XDG_CACHE_HOME"); 396 if (xdgCacheDir != null && !xdgCacheDir.isEmpty()) { 397 return new File(xdgCacheDir, Main.pref.getJOSMDirectoryBaseName()); 398 } else { 399 return new File(System.getProperty("user.home") + File.separator + 400 ".cache" + File.separator + Main.pref.getJOSMDirectoryBaseName()); 401 } 402 } 373 403 } 374 404 375 405 @Override 376 406 public File getDefaultPrefDirectory() { 377 return new File(System.getProperty("user.home"), ".josm"); 407 if (useDotDirectory()) { 408 return getDotDirectory(); 409 } else { 410 String xdgConfigDir = System.getenv("XDG_CONFIG_HOME"); 411 if (xdgConfigDir != null && !xdgConfigDir.isEmpty()) { 412 return new File(xdgConfigDir, Main.pref.getJOSMDirectoryBaseName()); 413 } else { 414 return new File(System.getProperty("user.home") + File.separator + 415 ".config" + File.separator + Main.pref.getJOSMDirectoryBaseName()); 416 } 417 } 378 418 } 379 419 380 420 @Override 381 421 public File getDefaultUserDataDirectory() { 382 // Use preferences directory by default 383 return Main.pref.getPreferencesDirectory(); 422 if (useDotDirectory()) { 423 return getDotDirectory(); 424 } else { 425 String xdgDataDir = System.getenv("XDG_DATA_HOME"); 426 if (xdgDataDir != null && !xdgDataDir.isEmpty()) { 427 return new File(xdgDataDir, Main.pref.getJOSMDirectoryBaseName()); 428 } else { 429 return new File(System.getProperty("user.home") + File.separator + 430 ".local" + File.separator + "share" + File.separator + Main.pref.getJOSMDirectoryBaseName()); 431 } 432 } 384 433 } 385 434 -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r11156 r11162 358 358 p = System.getenv("APPDATA"); 359 359 } 360 return new File(new File(p, "JOSM"), "cache");360 return new File(new File(p, Main.pref.getJOSMDirectoryBaseName()), "cache"); 361 361 } 362 362 363 363 @Override 364 364 public File getDefaultPrefDirectory() { 365 return new File(System.getenv("APPDATA"), "JOSM");365 return new File(System.getenv("APPDATA"), Main.pref.getJOSMDirectoryBaseName()); 366 366 } 367 367
Note:
See TracChangeset
for help on using the changeset viewer.