You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/08/06 23:42:39 UTC

[commons-io] branch master updated: Refactor for simpler subclassing.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
     new 3ac63df  Refactor for simpler subclassing.
     new 71bfef4  Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-io.git
3ac63df is described below

commit 3ac63df5d5660d14212b9dad50ef2da3d26305f3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Aug 6 19:42:08 2020 -0400

    Refactor for simpler subclassing.
---
 .../org/apache/commons/io/file/CopyDirectoryVisitor.java   | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/io/file/CopyDirectoryVisitor.java b/src/main/java/org/apache/commons/io/file/CopyDirectoryVisitor.java
index b5a39d5..ff25d31 100644
--- a/src/main/java/org/apache/commons/io/file/CopyDirectoryVisitor.java
+++ b/src/main/java/org/apache/commons/io/file/CopyDirectoryVisitor.java
@@ -55,6 +55,18 @@ public class CopyDirectoryVisitor extends CountingPathVisitor {
         this.copyOptions = copyOptions == null ? EMPTY_COPY_OPTIONS : copyOptions.clone();
     }
 
+    /**
+     * Copies the sourceFile to the targetFile.
+     *
+     * @param sourceFile the source file.
+     * @param targetFile the target file.
+     * @throws IOException if an I/O error occurs.
+     * @since 2.8.0
+     */
+    protected void copy(final Path sourceFile, final Path targetFile) throws IOException {
+        Files.copy(sourceFile, targetFile, copyOptions);
+    }
+
     @Override
     public FileVisitResult preVisitDirectory(final Path directory, final BasicFileAttributes attributes)
             throws IOException {
@@ -68,7 +80,7 @@ public class CopyDirectoryVisitor extends CountingPathVisitor {
     @Override
     public FileVisitResult visitFile(final Path sourceFile, final BasicFileAttributes attributes) throws IOException {
         final Path targetFile = targetDirectory.resolve(sourceDirectory.relativize(sourceFile));
-        Files.copy(sourceFile, targetFile, copyOptions);
+        copy(sourceFile, targetFile);
         return super.visitFile(targetFile, attributes);
     }