Changeset 9296 in josm for trunk/src/org/openstreetmap/josm/tools/Utils.java
- Timestamp:
- 2016-01-04T01:06:23+01:00 (10 years ago)
- File:
-
- 1 edited
-
trunk/src/org/openstreetmap/josm/tools/Utils.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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.
