Skip to content

Commit 3ac63df

Browse files
author
Gary Gregory
committed
Refactor for simpler subclassing.
1 parent 9741fb8 commit 3ac63df

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/main/java/org/apache/commons/io/file/CopyDirectoryVisitor.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ public CopyDirectoryVisitor(final PathCounters pathCounter, final Path sourceDir
5555
this.copyOptions = copyOptions == null ? EMPTY_COPY_OPTIONS : copyOptions.clone();
5656
}
5757

58+
/**
59+
* Copies the sourceFile to the targetFile.
60+
*
61+
* @param sourceFile the source file.
62+
* @param targetFile the target file.
63+
* @throws IOException if an I/O error occurs.
64+
* @since 2.8.0
65+
*/
66+
protected void copy(final Path sourceFile, final Path targetFile) throws IOException {
67+
Files.copy(sourceFile, targetFile, copyOptions);
68+
}
69+
5870
@Override
5971
public FileVisitResult preVisitDirectory(final Path directory, final BasicFileAttributes attributes)
6072
throws IOException {
@@ -68,7 +80,7 @@ public FileVisitResult preVisitDirectory(final Path directory, final BasicFileAt
6880
@Override
6981
public FileVisitResult visitFile(final Path sourceFile, final BasicFileAttributes attributes) throws IOException {
7082
final Path targetFile = targetDirectory.resolve(sourceDirectory.relativize(sourceFile));
71-
Files.copy(sourceFile, targetFile, copyOptions);
83+
copy(sourceFile, targetFile);
7284
return super.visitFile(targetFile, attributes);
7385
}
7486

0 commit comments

Comments
 (0)