in foundation/CDDBaselineJava/src/main/java/com/awslabs/aws/iot/greengrass/cdd/nativeprocesses/interfaces/NativeProcessHelper.java [27:70]
default List<Path> listAllFiles() {
Logger log = LoggerFactory.getLogger(NativeProcessHelper.class);
List<Path> output = new ArrayList<>();
try {
Instant startInstant = Instant.now();
// Adapted from - https://stackoverflow.com/questions/44007055/avoid-java-8-files-walk-termination-cause-of-java-nio-file-accessdeniedexc
Files.walkFileTree(new File("/").toPath(), new HashSet<>(),
Integer.MAX_VALUE, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// File, add to the list
output.add(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFileFailed(Path file, IOException e) throws IOException {
// Failed path, ignore it and the subtree (if it is a directory)
return FileVisitResult.SKIP_SUBTREE;
}
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
// Directory, add to the list
output.add(dir);
return FileVisitResult.CONTINUE;
}
});
Instant stopInstant = Instant.now();
Duration duration = Duration.between(startInstant, stopInstant);
log.debug("Time to walk filesystem: " + duration);
} catch (Exception e) {
log.error(e.getMessage());
}
return output;
}