Search in sources :

Example 86 with PathMatcher

use of java.nio.file.PathMatcher in project heron by twitter.

the class TopologyUtils method lookUpTopologyDefnFile.

public static String lookUpTopologyDefnFile(String dir, String filename) {
    String pattern = String.format("glob:%s/%s.defn", dir, filename);
    PathMatcher matcher = FileSystems.getDefault().getPathMatcher(pattern);
    for (File file : new File(dir).listFiles()) {
        if (matcher.matches(file.toPath())) {
            // We would return the first one matched
            return file.getPath();
        }
    }
    throw new IllegalStateException("Failed to find topology defn file");
}
Also used : PathMatcher(java.nio.file.PathMatcher) File(java.io.File)

Example 87 with PathMatcher

use of java.nio.file.PathMatcher in project winery by eclipse.

the class CsarImporter method handleExclude.

/**
 * Modifies given allFiles object to exclude all files given by the excl pattern
 * <p>
 * Semantics: Remove all files from the set, which match the given pattern
 */
private void handleExclude(Exclude excl, Path localRoot, Set<Path> allFiles) {
    PathMatcher pathMatcher = localRoot.getFileSystem().getPathMatcher("glob:" + excl.getPattern());
    allFiles.removeIf(pathMatcher::matches);
}
Also used : PathMatcher(java.nio.file.PathMatcher)

Aggregations

PathMatcher (java.nio.file.PathMatcher)87 Path (java.nio.file.Path)40 Test (org.junit.Test)23 IOException (java.io.IOException)22 File (java.io.File)16 ArrayList (java.util.ArrayList)12 FileSystem (java.nio.file.FileSystem)11 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)10 FileVisitResult (java.nio.file.FileVisitResult)9 Files (java.nio.file.Files)5 Paths (java.nio.file.Paths)5 HashSet (java.util.HashSet)5 List (java.util.List)5 ProjectHandlerRegistry (org.eclipse.che.api.project.server.handlers.ProjectHandlerRegistry)5 ProjectImporterRegistry (org.eclipse.che.api.project.server.importer.ProjectImporterRegistry)5 ProjectTypeRegistry (org.eclipse.che.api.project.server.type.ProjectTypeRegistry)5 DefaultFileWatcherNotificationHandler (org.eclipse.che.api.vfs.impl.file.DefaultFileWatcherNotificationHandler)5 FileTreeWatcher (org.eclipse.che.api.vfs.impl.file.FileTreeWatcher)5 LocalVirtualFileSystemProvider (org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystemProvider)5 FSLuceneSearcherProvider (org.eclipse.che.api.vfs.search.impl.FSLuceneSearcherProvider)5