/** * List the directory and create {@code SkyKey}s to request contents of its children recursively. * * <p>The returned keys are of type {@link SkyFunctions#RECURSIVE_FILESYSTEM_TRAVERSAL}. */ private static Collection<SkyKey> createRecursiveTraversalKeys( Environment env, TraversalRequest traversal) throws MissingDepException { // Use the traversal's path, even if it's a symlink. The contents of the directory, as listed // in the result, must be relative to it. DirectoryListingValue dirListing = (DirectoryListingValue) getDependentSkyValue(env, DirectoryListingValue.key(traversal.path)); List<SkyKey> result = new ArrayList<>(); for (Dirent dirent : dirListing.getDirents()) { RootedPath childPath = RootedPath.toRootedPath( traversal.path.getRoot(), traversal.path.getRelativePath().getRelative(dirent.getName())); TraversalRequest childTraversal = traversal.forChildEntry(childPath); result.add(RecursiveFilesystemTraversalValue.key(childTraversal)); } return result; }