Java Code Examples for java.nio.file.FileVisitResult#SKIP_SUBTREE
The following examples show how to use
java.nio.file.FileVisitResult#SKIP_SUBTREE .
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 File: AESKeyFileEncrypterFactoryTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Override public FileVisitResult preVisitDirectory(final Path dir, final BasicFileAttributes attrs) throws IOException { if(!_inKeysSubdir && dir.endsWith(_subdirName)) { _inKeysSubdir = true; assertFalse(Files.getPosixFilePermissions(dir).contains(PosixFilePermission.OTHERS_READ)); assertFalse(Files.getPosixFilePermissions(dir).contains(PosixFilePermission.OTHERS_WRITE)); assertFalse(Files.getPosixFilePermissions(dir).contains(PosixFilePermission.OTHERS_EXECUTE)); assertFalse(Files.getPosixFilePermissions(dir).contains(PosixFilePermission.GROUP_READ)); assertFalse(Files.getPosixFilePermissions(dir).contains(PosixFilePermission.GROUP_WRITE)); assertFalse(Files.getPosixFilePermissions(dir).contains(PosixFilePermission.GROUP_EXECUTE)); return FileVisitResult.CONTINUE; } else { return _inKeysSubdir ? FileVisitResult.SKIP_SUBTREE : FileVisitResult.CONTINUE; } }
Example 2
Source File: ModpackDetectorVisitor.java From SmartModInserter with GNU Lesser General Public License v3.0 | 6 votes |
@Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { out.println("Enter directory " + dir); Path modList = dir.resolve("mod-list.json"); if (!dir.getFileName().toString().equals("mods") && !dir.getFileName().toString().equals("downloads") && !Files.exists(modList) && dir.getParent().equals(store.getFMMDir())) { Modpack.writeModList(modList, false); } if (!dir.getFileName().toString().equals("mods") && !dir.getFileName().toString().equals("downloads") && Files.exists(modList)) { currentModpack = modpacks.stream().filter(m -> m.getPath().equals(dir)).findAny().orElseGet(() -> new Modpack(dir.getFileName().toString(), dir)); out.println("Enter modpack " + currentModpack.getName()); //remove all mods that are missing in the directory currentModpack.getMods().removeAll(currentModpack.getMods().stream().filter(mod -> !Files.exists(mod.getMod().getPath())).collect(Collectors.toList())); out.push(); return FileVisitResult.CONTINUE; } //check if we are in the root directory because this will be passed to us once. if (dir.getFileName().toString().equals("fmm")) { out.push(); return FileVisitResult.CONTINUE; } //skip directories without a mod-list.json file, because those aren't modpacks return FileVisitResult.SKIP_SUBTREE; }
Example 3
Source File: MoveFileVisitor.java From Java-Coding-Problems with MIT License | 6 votes |
@Override public FileVisitResult preVisitDirectory(Object dir, BasicFileAttributes attrs) throws IOException { System.out.println("Move directory: " + (Path) dir); Path newDir = moveTo.resolve(moveFrom.relativize((Path) dir)); try { Files.copy((Path) dir, newDir, REPLACE_EXISTING, COPY_ATTRIBUTES); time = Files.getLastModifiedTime((Path) dir); } catch (IOException e) { System.err.println("Unable to move " + newDir + " [" + e + "]"); return FileVisitResult.SKIP_SUBTREE; } return FileVisitResult.CONTINUE; }
Example 4
Source File: HomeDirectoryTreeWalker.java From artifactory_ssh_proxy with Apache License 2.0 | 5 votes |
@Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { dir = dir.toAbsolutePath(); // skip anything not in /home if (!dir.startsWith(getHomeDirectoryBasePath())) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Not visiting non-home dir {}", dir.toAbsolutePath()); } return FileVisitResult.SKIP_SUBTREE; } // skip paths that are excluded, as we may not want to scan some directories for various reasons. for (Path excluded : getExcludedPaths()) { if (dir.startsWith(excluded)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Not visiting excluded dir {}", dir.toAbsolutePath()); } return FileVisitResult.SKIP_SUBTREE; } } // skip anything that is more than homedir length+2 and not named .ssh final int dirCount = dir.getNameCount(); if (dirCount > getHomeDirNameCount() + 1 && !dir.endsWith(".ssh")) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Not visiting deep dir {}", dir.toAbsolutePath()); } return FileVisitResult.SKIP_SUBTREE; } register(dir); return FileVisitResult.CONTINUE; }
Example 5
Source File: FileTreeCreatorVC7.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) throws IOException { Boolean hide = false; DirAttributes newAttr = attributes.peek().clone(); String rPath; if (path.toAbsolutePath().toString().equals(this.startDir.toAbsolutePath().toString())){ rPath = startDir.toString(); } else { rPath = path.getFileName().toString(); } // check per config ignorePaths! for (BuildConfig cfg : allConfigs) { if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) { newAttr.setIgnore(cfg); } // Hide is always on all configs. And additional files are never hiddden if (cfg.matchesHidePath(path.toAbsolutePath().toString())) { hide = true; break; } } if (!hide) { wg.startTag("Filter", new String[] { "Name", rPath}); attributes.push(newAttr); return super.preVisitDirectory(path, attrs); } else { return FileVisitResult.SKIP_SUBTREE; } }
Example 6
Source File: FileUtils.java From FastCopy with Apache License 2.0 | 5 votes |
@Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { if (dir.equals(sourcePath)) return FileVisitResult.CONTINUE; else return recursive ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE; }
Example 7
Source File: Finder.java From XHAIL with GNU General Public License v3.0 | 5 votes |
@Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { Objects.nonNull(dir); // if (null != exc) // throw exc; return recurse ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE; }
Example 8
Source File: FileTreeCreatorVC7.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) throws IOException { Boolean hide = false; DirAttributes newAttr = attributes.peek().clone(); String rPath; if (path.toAbsolutePath().toString().equals(this.startDir.toAbsolutePath().toString())){ rPath = startDir.toString(); } else { rPath = path.getFileName().toString(); } // check per config ignorePaths! for (BuildConfig cfg : allConfigs) { if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) { newAttr.setIgnore(cfg); } // Hide is always on all configs. And additional files are never hiddden if (cfg.matchesHidePath(path.toAbsolutePath().toString())) { hide = true; break; } } if (!hide) { wg.startTag("Filter", new String[] { "Name", rPath}); attributes.push(newAttr); return super.preVisitDirectory(path, attrs); } else { return FileVisitResult.SKIP_SUBTREE; } }
Example 9
Source File: FileTreeCreatorVC10.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) throws IOException { Boolean hide = false; // TODO remove attrs, if path is matched in this dir, then it is too in every subdir. // And we will check anyway DirAttributes newAttr = attributes.peek().clone(); // check per config ignorePaths! for (BuildConfig cfg : allConfigs) { if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) { newAttr.setIgnore(cfg); } // Hide is always on all configs. And additional files are never hiddden if (cfg.matchesHidePath(path.toAbsolutePath().toString())) { hide = true; break; } } if (!hide) { String name = startDir.relativize(path.toAbsolutePath()).toString(); if (!"".equals(name)) { wg10.addFilter(name); } attributes.push(newAttr); return super.preVisitDirectory(path, attrs); } else { return FileVisitResult.SKIP_SUBTREE; } }
Example 10
Source File: ContractProjectUpdater.java From spring-cloud-contract with Apache License 2.0 | 5 votes |
@Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { Path relativePath = this.from.relativize(dir); if (".git".equals(relativePath.toString())) { return FileVisitResult.SKIP_SUBTREE; } Path targetPath = this.to.resolve(relativePath); if (!Files.exists(targetPath)) { if (log.isDebugEnabled()) { log.debug("Created a folder [" + targetPath.toString() + "]"); } Files.createDirectory(targetPath); } else { if (log.isDebugEnabled()) { log.debug("Folder [" + targetPath.toString() + "] already exists"); } if (FOLDERS_TO_DELETE.contains(targetPath.toFile().getName())) { if (log.isDebugEnabled()) { log.debug("Will remove the folder [" + targetPath.toString() + "]"); } deleteRecursively(targetPath); Files.createDirectory(targetPath); if (log.isDebugEnabled()) { log.debug("Recreated folder [" + targetPath.toString() + "]"); } } } return FileVisitResult.CONTINUE; }
Example 11
Source File: Bundler.java From gcs with Mozilla Public License 2.0 | 5 votes |
@Override public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) throws IOException { if (shouldSkip(path)) { return FileVisitResult.SKIP_SUBTREE; } return FileVisitResult.CONTINUE; }
Example 12
Source File: DirScanner.java From nohttp with Apache License 2.0 | 5 votes |
@Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { if (DirScanner.this.excludeDirs.stream().anyMatch(e -> e.test(dir.toFile()))) { return FileVisitResult.SKIP_SUBTREE; } return FileVisitResult.CONTINUE; }
Example 13
Source File: FileTreeCreatorVC7.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) throws IOException { Boolean hide = false; DirAttributes newAttr = attributes.peek().clone(); String rPath; if (path.toAbsolutePath().toString().equals(this.startDir.toAbsolutePath().toString())){ rPath = startDir.toString(); } else { rPath = path.getFileName().toString(); } // check per config ignorePaths! for (BuildConfig cfg : allConfigs) { if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) { newAttr.setIgnore(cfg); } // Hide is always on all configs. And additional files are never hiddden if (cfg.matchesHidePath(path.toAbsolutePath().toString())) { hide = true; break; } } if (!hide) { wg.startTag("Filter", new String[] { "Name", rPath}); attributes.push(newAttr); return super.preVisitDirectory(path, attrs); } else { return FileVisitResult.SKIP_SUBTREE; } }
Example 14
Source File: FileTreeCreatorVC10.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) throws IOException { Boolean hide = false; // TODO remove attrs, if path is matched in this dir, then it is too in every subdir. // And we will check anyway DirAttributes newAttr = attributes.peek().clone(); // check per config ignorePaths! for (BuildConfig cfg : allConfigs) { if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) { newAttr.setIgnore(cfg); } // Hide is always on all configs. And additional files are never hiddden if (cfg.matchesHidePath(path.toAbsolutePath().toString())) { hide = true; break; } } if (!hide) { String name = startDir.relativize(path.toAbsolutePath()).toString(); if (!"".equals(name)) { wg10.addFilter(name); } attributes.push(newAttr); return super.preVisitDirectory(path, attrs); } else { return FileVisitResult.SKIP_SUBTREE; } }
Example 15
Source File: Resources.java From es6draft with MIT License | 5 votes |
@Override public FileVisitResult preVisitDirectory(PATH path, BasicFileAttributes attrs) throws IOException { Path dir = basedir.relativize(path); if (fileMatcher.matchesDirectory(dir)) { return FileVisitResult.CONTINUE; } return FileVisitResult.SKIP_SUBTREE; }
Example 16
Source File: LicenseCheckTest.java From buck with Apache License 2.0 | 5 votes |
@Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { if (ignoreTestData && TEST_DATA.equals(dir.getFileName())) { return FileVisitResult.SKIP_SUBTREE; } if (NON_APACHE_LICENSE_DIRS_WHITELIST.contains(dir)) { return FileVisitResult.SKIP_SUBTREE; } return FileVisitResult.CONTINUE; }
Example 17
Source File: PreferenceInitializer.java From MergeProcessor with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { if (dir.equals(root)) { return FileVisitResult.CONTINUE; } else { final Path fileName = dir.getFileName(); if (fileName != null && fileName.startsWith("eclipse") && Files.exists(dir.resolve("eclipse.exe"))) { potentialEclipsePaths.add(dir); } return FileVisitResult.SKIP_SUBTREE; } }
Example 18
Source File: FileTreeCreatorVC10.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) throws IOException { Boolean hide = false; // TODO remove attrs, if path is matched in this dir, then it is too in every subdir. // And we will check anyway DirAttributes newAttr = attributes.peek().clone(); // check per config ignorePaths! for (BuildConfig cfg : allConfigs) { if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) { newAttr.setIgnore(cfg); } // Hide is always on all configs. And additional files are never hiddden if (cfg.matchesHidePath(path.toAbsolutePath().toString())) { hide = true; break; } } if (!hide) { String name = startDir.relativize(path.toAbsolutePath()).toString(); if (!"".equals(name)) { wg10.addFilter(name); } attributes.push(newAttr); return super.preVisitDirectory(path, attrs); } else { return FileVisitResult.SKIP_SUBTREE; } }
Example 19
Source File: JavaMaker.java From sis with Apache License 2.0 | 4 votes |
/** * Determines whether the given directory should be visited. * This method skips hidden directories. */ @Override public FileVisitResult preVisitDirectory(final Path dir, final BasicFileAttributes attrs) { return dir.getFileName().toString().startsWith(".") ? FileVisitResult.SKIP_SUBTREE : FileVisitResult.CONTINUE; }
Example 20
Source File: DeckFileVisitor.java From magarena with GNU General Public License v3.0 | 4 votes |
@Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { return DeckUtils.isValidDeckFolder(dir) ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE; }