Changeset 7835 in josm for trunk/src/org/openstreetmap/josm/tools/Utils.java
- Timestamp:
- 2014-12-19T16:15:43+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.