Changeset 12856 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2017-09-14T15:09:01+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r12855 r12856 331 331 * @return The user defined preferences directory, containing the preferences.xml file 332 332 * @since 7834 333 */ 333 * @deprecated use {@link #getPreferencesDirectory(boolean)} 334 */ 335 @Deprecated 336 public File getPreferencesDirectory() { 337 return getPreferencesDirectory(false); 338 } 339 334 340 @Override 335 public File getPreferencesDirectory( ) {341 public File getPreferencesDirectory(boolean createIfMissing) { 336 342 if (preferencesDir != null) 337 343 return preferencesDir; … … 348 354 } 349 355 } 356 if (createIfMissing && !preferencesDir.exists() && !preferencesDir.mkdirs()) { 357 Logging.warn(tr("Failed to create missing preferences directory: {0}", preferencesDir.getAbsoluteFile())); 358 JOptionPane.showMessageDialog( 359 Main.parent, 360 tr("<html>Failed to create missing preferences directory: {0}</html>", preferencesDir.getAbsoluteFile()), 361 tr("Error"), 362 JOptionPane.ERROR_MESSAGE 363 ); 364 } 350 365 return preferencesDir; 351 366 } … … 356 371 * @return The user data directory, containing autosave, plugins, etc. 357 372 * @since 7834 358 */ 373 * @deprecated use {@link #getUserDataDirectory(boolean)} 374 */ 375 @Deprecated 376 public File getUserDataDirectory() { 377 return getUserDataDirectory(false); 378 } 379 359 380 @Override 360 public File getUserDataDirectory( ) {381 public File getUserDataDirectory(boolean createIfMissing) { 361 382 if (userdataDir != null) 362 383 return userdataDir; … … 373 394 } 374 395 } 396 if (createIfMissing && !userdataDir.exists() && !userdataDir.mkdirs()) { 397 Logging.warn(tr("Failed to create missing user data directory: {0}", userdataDir.getAbsoluteFile())); 398 JOptionPane.showMessageDialog( 399 Main.parent, 400 tr("<html>Failed to create missing user data directory: {0}</html>", userdataDir.getAbsoluteFile()), 401 tr("Error"), 402 JOptionPane.ERROR_MESSAGE 403 ); 404 } 375 405 return userdataDir; 376 406 } … … 381 411 */ 382 412 public File getPreferenceFile() { 383 return new File(getPreferencesDirectory( ), "preferences.xml");413 return new File(getPreferencesDirectory(false), "preferences.xml"); 384 414 } 385 415 … … 389 419 */ 390 420 public File getDefaultsCacheFile() { 391 return new File(getCacheDirectory( ), "default_preferences.xml");421 return new File(getCacheDirectory(true), "default_preferences.xml"); 392 422 } 393 423 … … 397 427 */ 398 428 public File getPluginsDirectory() { 399 return new File(getUserDataDirectory( ), "plugins");429 return new File(getUserDataDirectory(false), "plugins"); 400 430 } 401 431 … … 406 436 * 407 437 * @return the cache directory 408 */ 438 * @deprecated use {@link #getCacheDirectory(boolean)} 439 */ 440 @Deprecated 441 public File getCacheDirectory() { 442 return getCacheDirectory(true); 443 } 444 409 445 @Override 410 public File getCacheDirectory( ) {446 public File getCacheDirectory(boolean createIfMissing) { 411 447 if (cacheDir != null) 412 448 return cacheDir; … … 427 463 } 428 464 } 429 if ( !cacheDir.exists() && !cacheDir.mkdirs()) {465 if (createIfMissing && !cacheDir.exists() && !cacheDir.mkdirs()) { 430 466 Logging.warn(tr("Failed to create missing cache directory: {0}", cacheDir.getAbsoluteFile())); 431 467 JOptionPane.showMessageDialog( … … 454 490 public Collection<String> getAllPossiblePreferenceDirs() { 455 491 Set<String> locations = new HashSet<>(); 456 addPossibleResourceDir(locations, getPreferencesDirectory( ).getPath());457 addPossibleResourceDir(locations, getUserDataDirectory( ).getPath());492 addPossibleResourceDir(locations, getPreferencesDirectory(false).getPath()); 493 addPossibleResourceDir(locations, getUserDataDirectory(false).getPath()); 458 494 addPossibleResourceDir(locations, System.getenv("JOSM_RESOURCES")); 459 495 addPossibleResourceDir(locations, System.getProperty("josm.resources")); … … 718 754 initSuccessful = false; 719 755 // get the preferences. 720 File prefDir = getPreferencesDirectory( );756 File prefDir = getPreferencesDirectory(false); 721 757 if (prefDir.exists()) { 722 758 if (!prefDir.isDirectory()) { -
trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
r12855 r12856 101 101 @SuppressWarnings("resource") 102 102 private static void initialize() throws IOException { 103 File cacheDir = new File(Config.getDirs().getCacheDirectory( ), "jcs");103 File cacheDir = new File(Config.getDirs().getCacheDirectory(true), "jcs"); 104 104 105 105 if (!cacheDir.exists() && !cacheDir.mkdirs()) -
trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java
r12855 r12856 56 56 String defPath = null; 57 57 try { 58 defPath = new File(Config.getDirs().getCacheDirectory( ), "tiles").getAbsolutePath();58 defPath = new File(Config.getDirs().getCacheDirectory(true), "tiles").getAbsolutePath(); 59 59 } catch (SecurityException e) { 60 60 Logging.warn(e); -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r12855 r12856 176 176 */ 177 177 public static String getValidatorDir() { 178 return new File(Config.getDirs().getUserDataDirectory( ), "validator").getAbsolutePath();178 return new File(Config.getDirs().getUserDataDirectory(true), "validator").getAbsolutePath(); 179 179 } 180 180
Note:
See TracChangeset
for help on using the changeset viewer.