Java Code Examples for java.nio.file.DirectoryStream

The following examples show how to use java.nio.file.DirectoryStream. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: big-c   Source File: IOUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Return the complete list of files in a directory as strings.<p/>
 *
 * This is better than File#listDir because it does not ignore IOExceptions.
 *
 * @param dir              The directory to list.
 * @param filter           If non-null, the filter to use when listing
 *                         this directory.
 * @return                 The list of files in the directory.
 *
 * @throws IOException     On I/O error
 */
public static List<String> listDirectory(File dir, FilenameFilter filter)
    throws IOException {
  ArrayList<String> list = new ArrayList<String> ();
  try (DirectoryStream<Path> stream =
           Files.newDirectoryStream(dir.toPath())) {
    for (Path entry: stream) {
      String fileName = entry.getFileName().toString();
      if ((filter == null) || filter.accept(dir, fileName)) {
        list.add(fileName);
      }
    }
  } catch (DirectoryIteratorException e) {
    throw e.getCause();
  }
  return list;
}
 
Example 2
public void iterateOverMFileCollection(Visitor visit) throws IOException {
  if (debug)
    System.out.printf(" iterateOverMFileCollection %s ", collectionDir);
  int count = 0;
  try (DirectoryStream<Path> ds = Files.newDirectoryStream(collectionDir, new MyStreamFilter())) {
    for (Path p : ds) {
      try {
        BasicFileAttributes attr = Files.readAttributes(p, BasicFileAttributes.class);
        if (!attr.isDirectory())
          visit.consume(new MFileOS7(p));
        if (debug)
          System.out.printf("%d ", count++);
      } catch (IOException ioe) {
        // catch error and skip file
        logger.error("Failed to read attributes from file found in Files.newDirectoryStream ", ioe);
      }
    }
  }
  if (debug)
    System.out.printf("%d%n", count);
}
 
Example 3
@Test
public void changeUserDirTest() throws ScriptException, IOException {
    System.setProperty("nashorn.persistent.code.cache", codeCache);
    final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
    final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_NOOPT);
    final Path codeCachePath = getCodeCachePath(false);
    final String newUserDir = "build/newUserDir";
    // Now changing current working directory
    System.setProperty("user.dir", System.getProperty("user.dir") + File.separator + newUserDir);
    try {
        // Check that a new compiled script is stored in existing code cache
        e.eval(code1);
        final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
        checkCompiledScripts(stream, 1);
        // Setting to default current working dir
    } finally {
        System.setProperty("user.dir", oldUserDir);
    }
}
 
Example 4
Source Project: crate   Source File: PluginsService.java    License: Apache License 2.0 6 votes vote down vote up
static void checkForFailedPluginRemovals(final Path pluginsDirectory) throws IOException {
    /*
     * Check for the existence of a marker file that indicates any plugins are in a garbage state from a failed attempt to remove the
     * plugin.
     */
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(pluginsDirectory, ".removing-*")) {
        final Iterator<Path> iterator = stream.iterator();
        if (iterator.hasNext()) {
            final Path removing = iterator.next();
            final String fileName = removing.getFileName().toString();
            final String name = fileName.substring(1 + fileName.indexOf("-"));
            final String message = String.format(
                    Locale.ROOT,
                    "found file [%s] from a failed attempt to remove the plugin [%s]; execute [elasticsearch-plugin remove %2$s]",
                    removing,
                    name);
            throw new IllegalStateException(message);
        }
    }
}
 
Example 5
Source Project: db   Source File: Version2to3.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
private void portApplication(final String appId) {
    logger.info("Upgrading application " + appId);

    /* Process every table */
    try {
        DirectoryStream<Path> stream = Files.newDirectoryStream(FileSystems.getDefault().getPath(BSql.BSQL_BASE_FOLDER + appId + BSql.SEPERATOR + BSql.DATABASE_FOLDER_NAME));
        stream.iterator().forEachRemaining(path -> {
            if (!path.toFile().isDirectory()) {
                return;
            }

            processTable(appId, path.getFileName().toString());
        });
    } catch (IOException ex) {
        java.util.logging.Logger.getLogger(Version2to3.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example 6
Source Project: mycore   Source File: MCRIView2Commands.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static void deleteFileAndEmptyDirectories(Path file) throws IOException {
    if (Files.isRegularFile(file)) {
        Files.delete(file);
    }
    if (Files.isDirectory(file)) {
        try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(file)) {
            for (@SuppressWarnings("unused")
            Path entry : directoryStream) {
                return;
            }
            Files.delete(file);
        }
    }
    Path parent = file.getParent();
    if (parent != null && parent.getNameCount() > 0) {
        deleteFileAndEmptyDirectories(parent);
    }
}
 
Example 7
/**
 * Resets the Mojo by setting {@link #mojo} to {@code null} and deletes the
 * test directory.
 *
 * @throws IOException Thrown if the test directory could not be deleted
 */
@After
public void tearDown() throws IOException {
    //Unset Mojo instance
    mojo = null;

    //Delete test directory
    final Path testDir = Paths.get(TEST_DIR);
    if (Files.exists(testDir)) {
        //First get all files in the test directory (if the test directory
        //exists and delete them. This is necessary because there is no
        //method for recursivly deleting a directory in the Java API.
        try (final DirectoryStream<Path> files = Files.newDirectoryStream(
            testDir)) {
            for (final Path file : files) {
                Files.deleteIfExists(file);
            }
        } catch (DirectoryIteratorException ex) {
            throw ex.getCause();
        }
        //Delete the (now empty) test directory.
        Files.deleteIfExists(testDir);
    }
}
 
Example 8
PollingWatchKey(Path dir, PollingWatchService watcher, Object fileKey)
    throws IOException
{
    super(dir, watcher);
    this.fileKey = fileKey;
    this.valid = true;
    this.tickCount = 0;
    this.entries = new HashMap<Path,CacheEntry>();

    // get the initial entries in the directory
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
        for (Path entry: stream) {
            // don't follow links
            long lastModified =
                Files.getLastModifiedTime(entry, LinkOption.NOFOLLOW_LINKS).toMillis();
            entries.put(entry.getFileName(), new CacheEntry(lastModified, tickCount));
        }
    } catch (DirectoryIteratorException e) {
        throw e.getCause();
    }
}
 
Example 9
Source Project: logging-log4j2   Source File: RollingAppenderCountTest.java    License: Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
    if (Files.exists(Paths.get(DIR))) {
        try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(Paths.get(DIR))) {
            for (final Path path : directoryStream) {
                Files.delete(path);
            }
            Files.delete(Paths.get(DIR));
        }
    }
    File dir = new File(DIR);
    if (!dir.exists()) {
        Files.createDirectory(new File(DIR).toPath());
    }
    Path target = Paths.get(DIR, TARGET + System.currentTimeMillis());
    Files.copy(Paths.get(SOURCE, FILENAME), target, StandardCopyOption.COPY_ATTRIBUTES);
}
 
Example 10
Source Project: crate   Source File: NodeEnvironment.java    License: Apache License 2.0 6 votes vote down vote up
private static List<Path> collectIndexSubPaths(NodePath[] nodePaths, Predicate<Path> subPathPredicate) throws IOException {
    List<Path> indexSubPaths = new ArrayList<>();
    for (NodePath nodePath : nodePaths) {
        Path indicesPath = nodePath.indicesPath;
        if (Files.isDirectory(indicesPath)) {
            try (DirectoryStream<Path> indexStream = Files.newDirectoryStream(indicesPath)) {
                for (Path indexPath : indexStream) {
                    if (Files.isDirectory(indexPath)) {
                        try (Stream<Path> shardStream = Files.list(indexPath)) {
                            shardStream.filter(subPathPredicate)
                                .map(Path::toAbsolutePath)
                                .forEach(indexSubPaths::add);
                        }
                    }
                }
            }
        }
    }

    return indexSubPaths;
}
 
Example 11
Source Project: hivemq-community-edition   Source File: PluginUtil.java    License: Apache License 2.0 6 votes vote down vote up
@NotNull
public static List<Path> findAllPluginFolders(@NotNull final Path pluginPath) throws IOException {

    checkNotNull(pluginPath, "provided extension folder path CAN NOT be null");

    final ImmutableList.Builder<Path> builder = ImmutableList.builder();
    try (final DirectoryStream<Path> stream = Files.newDirectoryStream(pluginPath)) {
        for (final Path path : stream) {
            if (PluginUtil.isValidPluginFolder(path, true)) {
                log.trace("Found extension folder {}", path.toString());
                builder.add(path);
            }
        }
    }
    return builder.build();
}
 
Example 12
Source Project: BIMserver   Source File: RemoveEmpty.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
private void start(String loc) {
	Path base = Paths.get(loc);
	try {
		DirectoryStream<Path> newDirectoryStream = Files.newDirectoryStream(base);
		for (Path p : newDirectoryStream) {
			DirectoryStream<Path> a = Files.newDirectoryStream(p);
			int c = 0;
			for (Path b : a) {
				c++;
			}
			if (c == 1) {
				org.apache.commons.io.FileUtils.deleteDirectory(p.toFile());
			}
		}
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
Example 13
@Override
public void process() {
    System.out.println("# jar_in_dir: " + root);
    if (!Files.exists(root)) {
        return;
    }
    try (DirectoryStream<Path> ds
            = Files.newDirectoryStream(root, "*.jar")) {
        for (Path p : ds) {
            new ClassPathJarEntry(p, executor).process();
            if (isFinished()) {
                return;
            }
        }
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}
 
Example 14
protected List<T> getAll(Path directory, String glob) throws IOException {
    List<T> objects = new ArrayList<>();

    try (DirectoryStream<Path> directoryStream = newDirectoryStream(directory, glob)) {
        for (Path path : directoryStream) {
            String id = getComponentId(path);
            Optional<T> e = tryGet(directory.resolve(format("%s/%s.json", id, id)));
            if (e.isPresent()) {
                objects.add(e.get());
            } else {
                logger.error(format("%s %s cannot be loaded, your repository may be corrupted",
                        type.getClass().getSimpleName(), id));
            }
        }
    }
    return objects;
}
 
Example 15
static void verifyInvokerBytecodeGenerator() throws Exception {
    int count = 0;
    int mcount = 0;
    try (DirectoryStream<Path> ds = newDirectoryStream(new File(".").toPath(),
            // filter in lambda proxy classes
            "A$I$$Lambda$?.class")) {
        for (Path p : ds) {
            System.out.println(p.toFile());
            ClassFile cf = ClassFile.read(p.toFile());
            // Check those methods implementing Supplier.get
            mcount += checkMethod(cf, "get");
            count++;
        }
    }
    if (count < 3) {
        throw new RuntimeException("unexpected number of files, "
                + "expected atleast 3 files, but got only " + count);
    }
    if (mcount < 3) {
        throw new RuntimeException("unexpected number of methods, "
                + "expected atleast 3 methods, but got only " + mcount);
    }
}
 
Example 16
@Override
public void process() {
    System.out.println("# jar_in_dir: " + root);
    if (!Files.exists(root)) {
        return;
    }
    try (DirectoryStream<Path> ds
            = Files.newDirectoryStream(root, "*.jar")) {
        for (Path p : ds) {
            new ClassPathJarEntry(p, executor).process();
            if (isFinished()) {
                return;
            }
        }
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}
 
Example 17
private List<Path> getClassPaths(String cpaths) {
    if (cpaths.isEmpty()) {
        return Collections.emptyList();
    }
    List<Path> paths = new ArrayList<>();
    for (String p : cpaths.split(File.pathSeparator)) {
        if (p.length() > 0) {
            // wildcard to parse all JAR files e.g. -classpath dir/*
            int i = p.lastIndexOf(".*");
            if (i > 0) {
                Path dir = Paths.get(p.substring(0, i));
                try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*.jar")) {
                    for (Path entry : stream) {
                        paths.add(entry);
                    }
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            } else {
                paths.add(Paths.get(p));
            }
        }
    }
    return paths;
}
 
Example 18
/**
 * Return the list of assets found in a repository
 */
public List<Asset> findAssetInPath(T component, AssetType type, Path directory) throws IOException {
    List<Asset> objects = new ArrayList<>();

    try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(directory)) {
        for (Path path : directoryStream) {
            objects.add(new Asset()
                    .setName(path.getFileName().toString())
                    .setType(type)
                    .setScope(AssetScope.forComponent(component))
                    .setComponentId(component.getId())
                    .setId(UUID.randomUUID().toString()));
        }
    }

    return objects;
}
 
Example 19
Source Project: helidon-build-tools   Source File: SourcePath.java    License: Apache License 2.0 6 votes vote down vote up
private static List<SourcePath> doScan(File root, File dir) {
    List<SourcePath> sourcePaths = new ArrayList<>();
    DirectoryStream<Path> dirStream = null;
    try {
        dirStream = Files.newDirectoryStream(dir.toPath());
        Iterator<Path> it = dirStream.iterator();
        while (it.hasNext()) {
            Path next = it.next();
            if (Files.isDirectory(next)) {
                sourcePaths.addAll(doScan(root, next.toFile()));
            } else {
                sourcePaths.add(new SourcePath(root, next.toFile()));
            }
        }
    } catch (IOException ex) {
        if (dirStream != null) {
            try {
                dirStream.close();
            } catch (IOException e) { }
        }
    }
    return sort(sourcePaths);
}
 
Example 20
Source Project: uyuni   Source File: CACertPathUtil.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static String findRpmCACert(Path docrootPath) {
    String candidateRpmCA = StringUtils.EMPTY;
    try (DirectoryStream<Path> directoryStream =
            Files.newDirectoryStream(docrootPath, CA_CRT_RPM_NAME + GLOB_NOARCH_RPM)) {
        for (Path rpmFile : directoryStream) {
            logger.debug("Found CA RPM file: " + candidateRpmCA);
            if (rpmFile.toString().compareTo(candidateRpmCA) > 0) {
                candidateRpmCA = rpmFile.toString();
            }
        }
        return candidateRpmCA;
    }
    catch (IOException | DirectoryIteratorException ex) {
        logger.warn("Cannot scan docroot " + docrootPath +
                " for CA RPM certificate. Exception: " + ex);
    }
    return candidateRpmCA;
}
 
Example 21
Source Project: storm-crawler   Source File: FileSpout.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param withDiscoveredStatus
 *            whether the tuples generated should contain a Status field
 *            with DISCOVERED as value and be emitted on the status stream
 * @param directory
 *            containing the seed files
 * @param filter
 *            to apply on the file names
 * @since 1.13
 **/
public FileSpout(String dir, String filter, boolean withDiscoveredStatus) {
    this.withDiscoveredStatus = withDiscoveredStatus;
    Path pdir = Paths.get(dir);
    _inputFiles = new LinkedList<>();
    LOG.info("Reading directory: {} (filter: {})", pdir, filter);
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(pdir,
            filter)) {
        for (Path entry : stream) {
            String inputFile = entry.toAbsolutePath().toString();
            _inputFiles.add(inputFile);
            LOG.info("Input : {}", inputFile);
        }
    } catch (IOException ioe) {
        LOG.error("IOException: %s%n", ioe);
    }
}
 
Example 22
Source Project: RipplePower   Source File: HtmlAssetTranslator.java    License: Apache License 2.0 6 votes vote down vote up
private static void translateOneLanguage(Path assetsDir, String language, final Collection<String> filesToTranslate)
		throws IOException {
	Path targetHtmlDir = assetsDir.resolve("html-" + language);
	Files.createDirectories(targetHtmlDir);
	Path englishHtmlDir = assetsDir.resolve("html-en");

	String translationTextTranslated = StringsResourceTranslator.translateString("Translated by Google Translate.",
			language);

	DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
		@Override
		public boolean accept(Path entry) {
			String name = entry.getFileName().toString();
			return name.endsWith(".html") && (filesToTranslate.isEmpty() || filesToTranslate.contains(name));
		}
	};
	try (DirectoryStream<Path> files = Files.newDirectoryStream(englishHtmlDir, filter)) {
		for (Path sourceFile : files) {
			translateOneFile(language, targetHtmlDir, sourceFile, translationTextTranslated);
		}
	}
}
 
Example 23
Source Project: Bytecoder   Source File: ExplodedImage.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public List<Node> getChildren() {
    if (!isDirectory())
        throw new IllegalArgumentException("not a directory: " + getNameString());
    if (children == null) {
        List<Node> list = new ArrayList<>();
        try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
            for (Path p : stream) {
                p = explodedModulesDir.relativize(p);
                String pName = MODULES + nativeSlashToFrontSlash(p.toString());
                Node node = findNode(pName);
                if (node != null) {  // findNode may choose to hide certain files!
                    list.add(node);
                }
            }
        } catch (IOException x) {
            return null;
        }
        children = list;
    }
    return children;
}
 
Example 24
Source Project: ratis   Source File: RaftStorageDirectory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @return log segment files sorted based on their index.
 */
public List<LogPathAndIndex> getLogSegmentFiles() throws IOException {
  List<LogPathAndIndex> list = new ArrayList<>();
  try (DirectoryStream<Path> stream =
           Files.newDirectoryStream(getCurrentDir().toPath())) {
    for (Path path : stream) {
      for (Pattern pattern : Arrays.asList(CLOSED_SEGMENT_REGEX, OPEN_SEGMENT_REGEX)) {
        Matcher matcher = pattern.matcher(path.getFileName().toString());
        if (matcher.matches()) {
          if (pattern == OPEN_SEGMENT_REGEX && Files.size(path) == 0L) {
            Files.delete(path);
            LOG.info("Delete zero size file " + path);
            break;
          }
          final long startIndex = Long.parseLong(matcher.group(1));
          final long endIndex = matcher.groupCount() == 2 ?
              Long.parseLong(matcher.group(2)) : INVALID_LOG_INDEX;
          list.add(new LogPathAndIndex(path, startIndex, endIndex));
          break;
        }
      }
    }
  }
  list.sort(Comparator.comparingLong(o -> o.startIndex));
  return list;
}
 
Example 25
Source Project: Elasticsearch   Source File: HunspellService.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Scans the hunspell directory and loads all found dictionaries
 */
private void scanAndLoadDictionaries() throws IOException {
    if (Files.isDirectory(hunspellDir)) {
        try (DirectoryStream<Path> stream = Files.newDirectoryStream(hunspellDir)) {
            for (Path file : stream) {
                if (Files.isDirectory(file)) {
                    try (DirectoryStream<Path> inner = Files.newDirectoryStream(hunspellDir.resolve(file), "*.dic")) {
                        if (inner.iterator().hasNext()) { // just making sure it's indeed a dictionary dir
                            try {
                                dictionaries.getUnchecked(file.getFileName().toString());
                            } catch (UncheckedExecutionException e) {
                                // The cache loader throws unchecked exception (see #loadDictionary()),
                                // here we simply report the exception and continue loading the dictionaries
                                logger.error("exception while loading dictionary {}", file.getFileName(), e);
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example 26
public int delete(User user, Function<Path, Boolean> filter) {
    log.debug("Removing all reporting data for {}", user.email);
    Path reportingFolderPath = getUserReportingFolderPath(user);

    int removedFilesCounter = 0;
    try {
        if (Files.exists(reportingFolderPath)) {
            try (DirectoryStream<Path> reportingFolder = Files.newDirectoryStream(reportingFolderPath, "*")) {
                for (Path reportingFile : reportingFolder) {
                    if (filter.apply(reportingFile)) {
                        log.trace("Removing {}", reportingFile);
                        FileUtils.deleteQuietly(reportingFile);
                        removedFilesCounter++;
                    }
                }
            }
        }
    } catch (Exception e) {
        log.error("Error removing file : {}.", reportingFolderPath);
    }
    return removedFilesCounter;
}
 
Example 27
Source Project: ignite   Source File: FileUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Add path to the stack if path is directory, otherwise delete it.
 *
 * @param paths Stack of paths.
 * @param ds Stream of paths.
 */
private static void appendOrRemove(LinkedList<Path> paths, DirectoryStream<Path> ds) throws IOException {
    for (Path p : ds) {
        if (Files.isDirectory(p))
            paths.add(p);
        else
            Files.delete(p);
    }
}
 
Example 28
Source Project: oryx   Source File: IOUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param dir directory to list
 * @param glob glob pattern for files that should be returned, which can span subdirectories
 *  as in patterns like {@code * /*}
 * @return {@link Path}s, including both files and directories, matching the glob pattern.
 *  No path containing an element whose name starts with "." is returned.
 *  Returned paths are also ordered lexicographically.
 * @throws IOException if an error occurs while accessing the file system
 */
public static List<Path> listFiles(Path dir, String glob) throws IOException {
  Preconditions.checkArgument(Files.isDirectory(dir), "%s is not a directory", dir);

  List<String> globLevels;
  if (glob == null || glob.isEmpty()) {
    globLevels = Collections.singletonList("*");
  } else {
    globLevels = Arrays.asList(glob.split("/"));
  }
  Preconditions.checkState(!globLevels.isEmpty());

  List<Path> paths = new ArrayList<>();
  paths.add(dir);

  for (String globLevel : globLevels) {
    List<Path> newPaths = new ArrayList<>();
    for (Path existingPath : paths) {
      if (Files.isDirectory(existingPath)) {
        try (DirectoryStream<Path> stream = Files.newDirectoryStream(existingPath, globLevel)) {
          for (Path path : stream) {
            if (!path.getFileName().toString().startsWith(".")) {
              newPaths.add(path);
            }
          }
        }
      }
    }
    paths = newPaths;
  }
  Collections.sort(paths);
  return paths;
}
 
Example 29
private void verifySymLinks(String bindir) throws IOException {
    File binDir = new File(bindir);
    System.err.println("verifying links in: " + bindir);
    File isaDir = new File(binDir, getArch()).getAbsoluteFile();
    if (!isaDir.exists()) {
        throw new RuntimeException("dir: " + isaDir + " does not exist");
    }
    try (DirectoryStream<Path> ds = Files.newDirectoryStream(binDir.toPath())) {
        for (Path p : ds) {
            if (symlinkExcludes.matcher(p.toString()).matches() ||
                    Files.isDirectory(p, NOFOLLOW_LINKS)) {
                continue;
            }
            Path link = new File(isaDir, p.getFileName().toString()).toPath();
            if (Files.isSymbolicLink(link)) {
                Path target = Files.readSymbolicLink(link);
                if (target.startsWith("..") && p.endsWith(target.getFileName())) {
                    // System.out.println(target + " OK");
                    continue;
                }
                System.err.println("target:" + target);
                System.err.println("file:" + p);
            }
            throw new RuntimeException("could not find link to " + p);
        }
    }

}
 
Example 30
/** If the file is a directory, list its contents. */
public Iterable<DocFile> list() throws IOException {
    List<DocFile> files = new ArrayList<DocFile>();
    try (DirectoryStream<Path> ds = Files.newDirectoryStream(file)) {
        for (Path f: ds) {
            files.add(new StandardDocFile(f));
        }
    }
    return files;
}