Changeset 7835 in josm
- Timestamp:
- 2014-12-19T16:15:43+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r7834 r7835 80 80 * <li>{@code resource://SOME/FILE} file from the classpath (usually in the current *.jar)</li> 81 81 * <li>{@code josmdir://SOME/FILE} file inside josm user data directory (since r7058)</li></ul> 82 * <li>{@code josmplugindir://SOME/FILE} file inside josm plugin directory (since r783 2)</li></ul>82 * <li>{@code josmplugindir://SOME/FILE} file inside josm plugin directory (since r7834)</li></ul> 83 83 */ 84 84 public CachedFile(String name) { … … 94 94 * <li>{@code resource://SOME/FILE} file from the classpath (usually in the current *.jar)</li> 95 95 * <li>{@code josmdir://SOME/FILE} file inside josm user data directory (since r7058)</li></ul> 96 * <li>{@code josmplugindir://SOME/FILE} file inside josm plugin directory (since r783 2)</li></ul>96 * <li>{@code josmplugindir://SOME/FILE} file inside josm plugin directory (since r7834)</li></ul> 97 97 * @return this object 98 98 */ -
trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r7834 r7835 38 38 // They just insist on painting themselves... 39 39 Preferences.updateSystemProperty("apple.laf.useScreenMenuBar", "true"); 40 migrateOldDirectory(); 40 41 } 41 42 … … 338 339 return new File(System.getProperty("user.home")+"/Library/Application Support", "JOSM"); 339 340 } 341 342 /*** 343 * Prior to r7834, JOSM used the same Unix directory ~/.josm for all local files (preferences, 344 * caches, user data). This method migrates the existing preferences and plugins to new directories 345 * if applicable. Old directory, including cache, is deleted. 346 * Method to remove end of 2015. 347 * @since 7835 348 */ 349 public static void migrateOldDirectory() { 350 File oldDir = new File(System.getProperty("user.home"), ".josm"); 351 if (oldDir.exists()) { 352 boolean error = false; 353 354 File oldPref = new File(oldDir, "preferences.xml"); 355 if (oldPref.exists()) { 356 File newPref = Main.pref.getPreferenceFile(); 357 if (!newPref.exists()) { 358 try { 359 Main.pref.getPreferencesDirectory().mkdirs(); 360 Main.info("Copying old preferences file to new location"); 361 Utils.copyFile(oldPref, newPref); 362 if (!oldPref.delete()) { 363 Main.warn("Unable to delete old preferences file: "+oldPref.getPath()); 364 } 365 } catch (IOException e) { 366 Main.error(e); 367 error = true; 368 } 369 } 370 } 371 372 File oldPlugins = new File(oldDir, "plugins"); 373 if (oldPlugins.exists()) { 374 File newPlugins = Main.pref.getPluginsDirectory(); 375 if (!newPlugins.exists()) { 376 try { 377 Utils.copyDirectory(oldPlugins, newPlugins); 378 } catch (IOException e) { 379 Main.error(e); 380 error = true; 381 } 382 } 383 } 384 385 if (!error) { 386 Main.info("Deleting old preferences directory"); 387 if (!Utils.deleteDirectory(oldDir)) { 388 Main.warn("Unable to delete old preferences directory"); 389 } 390 } 391 } 392 } 340 393 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r7556 r7835 324 324 325 325 /** 326 * Simple file copy function that will overwrite the target file. <br>326 * Simple file copy function that will overwrite the target file. 327 327 * @param in The source file 328 328 * @param out The destination file … … 332 332 * @since 7003 333 333 */ 334 public static Path copyFile(File in, File out) throws IOException , IllegalArgumentException{334 public static Path copyFile(File in, File out) throws IOException { 335 335 CheckParameterUtil.ensureParameterNotNull(in, "in"); 336 336 CheckParameterUtil.ensureParameterNotNull(out, "out"); 337 337 return Files.copy(in.toPath(), out.toPath(), StandardCopyOption.REPLACE_EXISTING); 338 } 339 340 /** 341 * Recursive directory copy function 342 * @param in The source directory 343 * @param out The destination directory 344 * @throws IOException If any I/O error ooccurs 345 * @throws IllegalArgumentException If {@code in} or {@code out} is {@code null} 346 * @since 7835 347 */ 348 public static void copyDirectory(File in, File out) throws IOException { 349 CheckParameterUtil.ensureParameterNotNull(in, "in"); 350 CheckParameterUtil.ensureParameterNotNull(out, "out"); 351 if (!out.exists() && !out.mkdirs()) { 352 Main.warn("Unable to create directory "+out.getPath()); 353 } 354 for (File f : in.listFiles()) { 355 File target = new File(out, f.getName()); 356 if (f.isDirectory()) { 357 copyDirectory(f, target); 358 } else { 359 copyFile(f, target); 360 } 361 } 338 362 } 339 363 … … 349 373 } 350 374 375 /** 376 * Deletes a directory recursively. 377 * @param path The directory to delete 378 * @return <code>true</code> if and only if the file or directory is 379 * successfully deleted; <code>false</code> otherwise 380 */ 351 381 public static boolean deleteDirectory(File path) { 352 382 if( path.exists() ) { … … 355 385 if (file.isDirectory()) { 356 386 deleteDirectory(file); 357 } else { 358 file.delete();387 } else if (!file.delete()) { 388 Main.warn("Unable to delete file: "+file.getPath()); 359 389 } 360 390 } 361 391 } 362 return (path.delete());392 return path.delete(); 363 393 } 364 394
Note:
See TracChangeset
for help on using the changeset viewer.