Ejemplo n.º 1
0
 // Set type of file as name of the element
 private void setType(Element element, Path path) {
   if (Files.isDirectory(path)) {
     element.setLocalName(FileType.DIR.getName());
     return;
   } else if (Files.isRegularFile(path)) {
     element.setLocalName(FileType.FILE.getName());
     return;
   } else if (Files.isSymbolicLink(path)) {
     element.setLocalName(FileType.SYMLINK.getName());
     return;
   } else element.setLocalName(FileType.OTHER.getName());
 }
Ejemplo n.º 2
0
 @Override
 public FileVisitResult visitFile(Path file, BasicFileAttributes attr) {
   if (currentDepth >= 0) {
     if (!Files.isReadable(file) || Files.isSymbolicLink(file)) return FileVisitResult.CONTINUE;
     try {
       addPathToTree(file, currentDepth);
       return FileVisitResult.CONTINUE;
     } catch (IOException e) {
       LOG.info(e.getMessage());
       return FileVisitResult.CONTINUE;
     }
   } else return FileVisitResult.SKIP_SIBLINGS;
 }
Ejemplo n.º 3
0
  @Override
  public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attr) {
    if (currentDepth >= 0) {
      if (!Files.isReadable(dir) || Files.isSymbolicLink(dir)) {
        return FileVisitResult.SKIP_SUBTREE;
      }

      try {
        addPathToTree(dir, currentDepth);
        dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE);
        currentDepth--;
        return FileVisitResult.CONTINUE;
      } catch (IOException e) {
        LOG.info(e.getMessage());
        return FileVisitResult.SKIP_SUBTREE;
      }
    } else return FileVisitResult.SKIP_SIBLINGS;
  }