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 52f3de5  Behavior seems to have changed from 2.6, use 
FileVisitOption.FOLLOW_LINKS to remedy.
52f3de5 is described below

commit 52f3de5ed66574742d4eb34ead1b330c7b10e6c1
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Jul 6 17:43:26 2020 -0400

    Behavior seems to have changed from 2.6, use
    FileVisitOption.FOLLOW_LINKS to remedy.
---
 .../java/org/apache/commons/io/file/PathUtils.java | 29 +++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/io/file/PathUtils.java 
b/src/main/java/org/apache/commons/io/file/PathUtils.java
index 718e131..11534f0 100644
--- a/src/main/java/org/apache/commons/io/file/PathUtils.java
+++ b/src/main/java/org/apache/commons/io/file/PathUtils.java
@@ -153,7 +153,22 @@ public final class PathUtils {
      * @throws IOException if an I/O error is thrown by a visitor method.
      */
     public static PathCounters cleanDirectory(final Path directory) throws 
IOException {
-        return visitFileTree(CleaningPathVisitor.withLongCounters(), 
directory).getPathCounters();
+        return cleanDirectory(directory, FileVisitOption.FOLLOW_LINKS);
+    }
+
+    /**
+     * Cleans a directory including sub-directories without deleting 
directories.
+     *
+     * @param directory directory to clean.
+     * @param fileVisitOptions See {@link 
Files#walkFileTree(Path,Set,int,FileVisitor)}.
+     * @return The visitation path counters.
+     * @throws IOException if an I/O error is thrown by a visitor method.
+     * @since 2.9
+     */
+    public static PathCounters cleanDirectory(final Path directory, final 
FileVisitOption... fileVisitOptions)
+        throws IOException {
+        return visitFileTree(CleaningPathVisitor.withLongCounters(), 
directory, toFileVisitOptionSet(fileVisitOptions),
+            Integer.MAX_VALUE).getPathCounters();
     }
 
     /**
@@ -262,6 +277,18 @@ public final class PathUtils {
      * @throws IOException if an I/O error is thrown by a visitor method.
      */
     public static PathCounters deleteDirectory(final Path directory) throws 
IOException {
+        return deleteDirectory(directory, FileVisitOption.FOLLOW_LINKS);
+    }
+
+    /**
+     * Deletes a directory including sub-directories.
+     *
+     * @param directory directory to delete.
+     * @param fileVisitOptions See {@link 
Files#walkFileTree(Path,Set,int,FileVisitor)}.
+     * @return The visitor used to delete the given directory.
+     * @throws IOException if an I/O error is thrown by a visitor method.
+     */
+    public static PathCounters deleteDirectory(final Path directory, final 
FileVisitOption... fileVisitOptions) throws IOException {
         return visitFileTree(DeletingPathVisitor.withLongCounters(), 
directory).getPathCounters();
     }
 

Reply via email to