use of org.neo4j.internal.helpers.collection.CombiningIterator in project neo4j by neo4j.
the class EphemeralFileSystemAbstraction method listFiles.
@Override
public Path[] listFiles(Path directory) throws IOException {
directory = canonicalFile(directory);
if (files.containsKey(directory)) {
throw new NotDirectoryException(directory.toString());
}
if (!directories.contains(directory)) {
throw new NoSuchFileException(directory.toString());
}
Set<Path> found = new HashSet<>();
Iterator<Path> filesAndFolders = new CombiningIterator<>(asList(this.files.keySet().iterator(), directories.iterator()));
while (filesAndFolders.hasNext()) {
Path file = filesAndFolders.next();
if (directory.equals(file.getParent())) {
found.add(file);
}
}
return found.toArray(new Path[0]);
}
use of org.neo4j.internal.helpers.collection.CombiningIterator in project neo4j by neo4j.
the class EphemeralFileSystemAbstraction method listFiles.
@Override
public Path[] listFiles(Path directory, DirectoryStream.Filter<Path> filter) {
directory = canonicalFile(directory);
if (files.containsKey(directory)) // This means that you're trying to list files on a file, not a directory.
{
return null;
}
Set<Path> found = new HashSet<>();
Iterator<Path> files = new CombiningIterator<>(asList(this.files.keySet().iterator(), directories.iterator()));
while (files.hasNext()) {
Path path = files.next();
if (directory.equals(path.getParent())) {
try {
if (filter.accept(path)) {
found.add(path);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
return found.toArray(new Path[0]);
}
Aggregations