use of java.nio.file.PathMatcher in project sts4 by spring-projects.
the class BasicFileObserver method notify.
private static void notify(Map<String, ImmutablePair<List<PathMatcher>, Consumer<String>>> registry, String uri) {
Path path = Paths.get(URI.create(uri));
registry.values().stream().filter(pair -> pair.left.stream().filter(matcher -> matcher.matches(path)).findFirst().isPresent()).forEach(pair -> pair.right.accept(uri));
}
use of java.nio.file.PathMatcher in project sonar-java by SonarSource.
the class AbstractJavaClasspath method getMatchingLibraries.
private static Set<File> getMatchingLibraries(String pattern, Path dir) throws IOException {
Set<File> matches = new LinkedHashSet<>();
Set<File> dirs = getMatchingDirs(pattern, dir);
PathMatcher matcher = FileSystems.getDefault().getPathMatcher(getGlob(dir, pattern));
for (File d : dirs) {
matches.addAll(getLibs(d.toPath()));
}
matches.addAll(dirs);
matches.addAll(new LibraryFinder().find(dir, matcher));
if (pattern.startsWith("**/")) {
// match jar in the base dir when using wildcard
matches.addAll(new LibraryFinder().find(dir, FileSystems.getDefault().getPathMatcher(getGlob(dir, pattern.substring(3)))));
}
return matches;
}
use of java.nio.file.PathMatcher in project moco by dreamhead.
the class Globs method doGlob.
private static ImmutableList<String> doGlob(final Path path, final Path searchPath) {
final PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + path);
try {
final ImmutableList.Builder<String> builder = ImmutableList.builder();
Files.walkFileTree(searchPath, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) {
if (matcher.matches(file)) {
builder.add(file.toString());
}
return FileVisitResult.CONTINUE;
}
});
return builder.build();
} catch (IOException e) {
throw new MocoException(e);
}
}
use of java.nio.file.PathMatcher in project moco by dreamhead.
the class MocoMount method include.
public static MountPredicate include(final String glob) {
checkNotNullOrEmpty(glob, "Glob should not be null or empty");
final PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + glob);
return filename -> matcher.matches(Paths.get(filename));
}
use of java.nio.file.PathMatcher in project jadx by skylot.
the class TestInput method decompile.
private void decompile(String tmpDirName, String... inputSamples) throws URISyntaxException, IOException {
List<String> args = new ArrayList<>();
Path tempDir = FileUtils.createTempDir(tmpDirName);
args.add("-v");
args.add("-d");
args.add(tempDir.toAbsolutePath().toString());
for (String inputSample : inputSamples) {
URL resource = getClass().getClassLoader().getResource(inputSample);
assertThat(resource).isNotNull();
String sampleFile = resource.toURI().getRawPath();
args.add(sampleFile);
}
int result = JadxCLI.execute(args.toArray(new String[0]));
assertThat(result).isEqualTo(0);
List<Path> resultJavaFiles = collectJavaFilesInDir(tempDir);
assertThat(resultJavaFiles).isNotEmpty();
// do not copy input files as resources
PathMatcher logAllFiles = path -> {
LOG.debug("File in result dir: {}", path);
return true;
};
for (Path path : collectFilesInDir(tempDir, logAllFiles)) {
for (String inputSample : inputSamples) {
assertThat(path.toAbsolutePath().toString()).doesNotContain(inputSample);
}
}
}
Aggregations