Changeset 9296 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2016-01-04T01:06:23+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/PlatformHookOsx.java
r8923 r9296 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 … … 366 367 Main.info("Copying old preferences file to new location"); 367 368 Utils.copyFile(oldPref, newPref); 368 if (!oldPref.delete()) { 369 Main.warn("Unable to delete old preferences file: "+oldPref.getPath()); 370 } 369 Utils.deleteFile(oldPref, marktr("Unable to delete old preferences file {0}")); 371 370 } catch (IOException e) { 372 371 Main.error(e); -
trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
r9073 r9296 190 190 public boolean rename(File from, File to) { 191 191 if (to.exists()) 192 to.delete();192 Utils.deleteFile(to); 193 193 return from.renameTo(to); 194 194 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r9280 r9296 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import static org.openstreetmap.josm.tools.I18n.trn; … … 446 447 if (file.isDirectory()) { 447 448 deleteDirectory(file); 448 } else if (!file.delete()){449 Main.warn("Unable to delete file: "+file.getPath());449 } else { 450 deleteFile(file); 450 451 } 451 452 } … … 453 454 } 454 455 return path.delete(); 456 } 457 458 /** 459 * Deletes a file and log a default warning if the deletion fails. 460 * @param file file to delete 461 * and must contain a single parameter <code>{0}</code> for the file path 462 * @return {@code true} if and only if the file is successfully deleted; {@code false} otherwise 463 * @since XXXX 464 */ 465 public static boolean deleteFile(File file) { 466 return deleteFile(file, marktr("Unable to delete file {0}")); 467 } 468 469 /** 470 * Deletes a file and log a configurable warning if the deletion fails. 471 * @param file file to delete 472 * @param warnMsg warning message. It will be translated with {@code tr()} 473 * and must contain a single parameter <code>{0}</code> for the file path 474 * @return {@code true} if and only if the file is successfully deleted; {@code false} otherwise 475 * @since XXXX 476 */ 477 public static boolean deleteFile(File file, String warnMsg) { 478 boolean result = file.delete(); 479 if (!result) { 480 Main.warn(tr(warnMsg, file.getPath())); 481 } 482 return result; 455 483 } 456 484
Note:
See TracChangeset
for help on using the changeset viewer.