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 a6774dbc Add FilesUncheck.find(Path, int, BiPredicate<Path, 
BasicFileAttributes>, FileVisitOption...)
a6774dbc is described below

commit a6774dbcc4361ff0accec0126890acdbb458338d
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Tue Jun 13 20:00:16 2023 -0400

    Add FilesUncheck.find(Path, int, BiPredicate<Path, BasicFileAttributes>,
    FileVisitOption...)
---
 src/changes/changes.xml                                 |  3 +++
 .../java/org/apache/commons/io/file/FilesUncheck.java   | 17 +++++++++++++++++
 .../org/apache/commons/io/file/FilesUncheckTest.java    |  5 +++++
 3 files changed, 25 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 9265b572..71523ced 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -58,6 +58,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="add" due-to="Gary Gregory">
         Add IOUtils.skip[Fully](InputStream, long, Supplier&lt;byte[]&gt;).
       </action>
+      <action dev="ggregory" type="add" due-to="Gary Gregory">
+        Add FilesUncheck.find(Path, int, BiPredicate%lt;Path, 
BasicFileAttributes&gt;, FileVisitOption...)
+      </action>
       <!-- FIX -->
       <action dev="ggregory" type="fix" issue="IO-799" due-to="Jeroen van der 
Vegt, Gary Gregory">
         ReaderInputStream.read() throws an exception instead of returning -1 
when called again after returning -1.
diff --git a/src/main/java/org/apache/commons/io/file/FilesUncheck.java 
b/src/main/java/org/apache/commons/io/file/FilesUncheck.java
index e99d09cc..02a1febb 100644
--- a/src/main/java/org/apache/commons/io/file/FilesUncheck.java
+++ b/src/main/java/org/apache/commons/io/file/FilesUncheck.java
@@ -42,6 +42,7 @@ import java.nio.file.attribute.UserPrincipal;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.function.BiPredicate;
 import java.util.stream.Stream;
 
 import org.apache.commons.io.function.Uncheck;
@@ -241,6 +242,22 @@ public final class FilesUncheck {
         return Uncheck.apply(Files::deleteIfExists, path);
     }
 
+    /**
+     * Delegates to {@link Files#find(Path, int, BiPredicate, 
FileVisitOption...)} throwing {@link UncheckedIOException} instead of {@link 
IOException}.
+     *
+     * @param start    See delegate.
+     * @param maxDepth See delegate.
+     * @param matcher  See delegate.
+     * @param options  See delegate.
+     * @return See delegate.
+     * @throws UncheckedIOException Wraps an {@link IOException}.
+     * @since 2.14.0
+     */
+    public static Stream<Path> find(final Path start, final int maxDepth, 
final BiPredicate<Path, BasicFileAttributes> matcher,
+            final FileVisitOption... options) {
+        return Uncheck.apply(Files::find, start, maxDepth, matcher, options);
+    }
+
     /**
      * Delegates to {@link Files#getAttribute(Path, String, LinkOption...)} 
throwing {@link UncheckedIOException} instead of
      * {@link IOException}.
diff --git a/src/test/java/org/apache/commons/io/file/FilesUncheckTest.java 
b/src/test/java/org/apache/commons/io/file/FilesUncheckTest.java
index 18823532..4fa73681 100644
--- a/src/test/java/org/apache/commons/io/file/FilesUncheckTest.java
+++ b/src/test/java/org/apache/commons/io/file/FilesUncheckTest.java
@@ -164,6 +164,11 @@ public class FilesUncheckTest {
         assertFalse(FilesUncheck.deleteIfExists(NEW_FILE_PATH));
     }
 
+    @Test
+    public void testFind() {
+        assertNotNull(FilesUncheck.find(FILE_PATH_EMPTY, 0, (t, u) -> false));
+    }
+
     @Test
     public void testGetAttribute() {
         assertEquals(0L, FilesUncheck.getAttribute(FILE_PATH_EMPTY, 
"basic:size", LinkOption.NOFOLLOW_LINKS));

Reply via email to