in log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/util/FileUtils.java [37:64]
public static <V> V findAdjacentFiles(
final Path directory,
final boolean dotFilesSkipped,
final Function<Stream<Path>, V> consumer) {
try (final Stream<Path> paths = Files.walk(directory, 1)) {
final Stream<Path> filteredPaths = paths.filter(path -> {
// Skip the directory itself
if (path.equals(directory)) {
return false;
}
// Skip hidden files
boolean hiddenFile = dotFilesSkipped && path.getFileName().toString().startsWith(".");
if (hiddenFile) {
return false;
}
// Accept the rest
return true;
});
return consumer.apply(filteredPaths);
} catch (final IOException error) {
final String message = String.format("failed walking directory: `%s`", directory);
throw new UncheckedIOException(message, error);
}
}