create F.isNotEmptyDirectory() as an opposite to F.isEmptyDirectory() (fixing call to !F.isEmptyDirectory()) revert some FileSnapshot.getStream() changes
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0693a9a7 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0693a9a7 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0693a9a7 Branch: refs/heads/ignite-gg-8.0.3.ea6-clients-test Commit: 0693a9a7eb0f4c7b3fd7109885f1e1150f4da126 Parents: 476e8f1 Author: Alexandr Kuramshin <[email protected]> Authored: Sun Mar 19 00:08:50 2017 +0700 Committer: Alexandr Kuramshin <[email protected]> Committed: Sun Mar 19 00:08:50 2017 +0700 ---------------------------------------------------------------------- .../ignite/internal/util/lang/GridFunc.java | 21 ++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/0693a9a7/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java index 4ddf615..fff76cb 100755 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java @@ -2318,10 +2318,10 @@ public class GridFunc { } /** - * Tests if the given path is a directory and is not {@code null} or empty. + * Tests if the given path is not {@code null} and is an empty directory. * * @param dir Path to test. - * @return Whether or not the given path is a directory and is not {@code null} or empty. + * @return Whether or not the given path is not {@code null} and is an empty directory. */ public static boolean isEmptyDirectory(Path dir) { if (dir == null || !Files.isDirectory(dir)) @@ -2335,6 +2335,23 @@ public class GridFunc { } /** + * Tests if the given path is not {@code null} and is a not empty directory. + * + * @param dir Path to test. + * @return Whether or not the given path is not {@code null} and is a not empty directory. + */ + public static boolean isNotEmptyDirectory(Path dir) { + if (dir == null || !Files.isDirectory(dir)) + return false; + try (DirectoryStream<Path> files = Files.newDirectoryStream(dir)) { + return files.iterator().hasNext(); + } + catch (IOException e) { + throw new IgniteException(e); + } + } + + /** * Converts collection of numbers to primitive {@code int[]} array. * * @param col Collection of numbers.
