use of org.eclipse.winery.common.ids.GenericId in project winery by eclipse.
the class FilebasedRepository method getContainedFiles.
@Override
public SortedSet<RepositoryFileReference> getContainedFiles(GenericId id) {
Path dir = this.id2AbsolutePath(id);
SortedSet<RepositoryFileReference> res = new TreeSet<>();
if (!Files.exists(dir)) {
return res;
}
assert (Files.isDirectory(dir));
final OnlyNonHiddenFiles onlyNonHiddenFiles = new OnlyNonHiddenFiles();
try {
Files.walk(dir).filter(f -> {
try {
return onlyNonHiddenFiles.accept(f);
} catch (IOException e) {
LOGGER.debug("Error during crawling", e);
return false;
}
}).map(f -> {
final Path relativePath = dir.relativize(f.getParent());
if (relativePath.toString().isEmpty()) {
return new RepositoryFileReference(id, f.getFileName().toString());
} else {
return new RepositoryFileReference(id, relativePath, f.getFileName().toString());
}
}).forEach(ref -> res.add(ref));
} catch (IOException e1) {
LOGGER.debug("Error during crawling", e1);
}
return res;
}
Aggregations