public static List findDirs()

in src/main/java/org/apache/netbeans/nbpackage/FileUtils.java [248:268]


    public static List<Path> findDirs(Path searchDir, int searchDepth, String... patterns) throws IOException {
        var matchers = Stream.of(patterns)
                .map(p -> FileSystems.getDefault().getPathMatcher("glob:" + p))
                .collect(Collectors.toList());
        var intDepth = Stream.of(patterns)
                .map(p -> p.split("/"))
                .mapToInt(ps -> ps.length)
                .max().orElse(1);
        try (var stream = Files.find(searchDir, searchDepth, (intPath, attr) -> {
            return matchers.stream().map(m -> {
                try (var files = Files.walk(intPath, intDepth)) {
                    return files.map(file -> intPath.relativize(file))
                            .anyMatch(m::matches);
                } catch (IOException ex) {
                    return false;
                }
            }).allMatch(v -> v);
        })) {
            return List.copyOf(stream.collect(Collectors.toList()));
        }
    }