private static Path calculateArchive( String database, Path to ) { return Files.isDirectory( to ) ? to.resolve( database + ".dump" ) : to; }
public static boolean isDirExists(Path dirPath) { return dirPath != null && Files.exists(dirPath) && Files.isDirectory(dirPath); }
Path normalizedAbsolutePath = path.toAbsolutePath().normalize(); Path parent = normalizedAbsolutePath.getParent(); if (parent == null) { if (!Files.isDirectory(parent)) { Files.createDirectories(parent, attrs); if (!Files.isDirectory(parent)) { throw new IOException("Unable to create parent directories of " + path);
private void forEachTopologyDistDir(ConsumePathAndId consumer) throws IOException { Path stormCodeRoot = Paths.get(ConfigUtils.supervisorStormDistRoot(conf)); if (Files.exists(stormCodeRoot) && Files.isDirectory(stormCodeRoot)) { try (DirectoryStream<Path> children = Files.newDirectoryStream(stormCodeRoot)) { for (Path child : children) { if (Files.isDirectory(child)) { String topologyId = child.getFileName().toString(); consumer.accept(child, topologyId); } } } } }
public static boolean isDirectory(File file) { try { return Files.isDirectory(Paths.get(file.getAbsolutePath()), LinkOption.NOFOLLOW_LINKS); } catch (InvalidPathException e) { return false; } }
private JavaContainerBuilder addDirectory( Path directory, AbsoluteUnixPath destination, LayerType layerType, Predicate<Path> pathFilter) throws IOException { if (!Files.exists(directory)) { throw new NoSuchFileException(directory.toString()); } if (!Files.isDirectory(directory)) { throw new NotDirectoryException(directory.toString()); } layerConfigurationsBuilder.addDirectoryContents(layerType, directory, pathFilter, destination); classpath.add(destination.toString()); return this; } }
private static Path getSourcePath() { Path workingDir = Paths.get(System.getProperty("user.dir")); verify(isDirectory(workingDir), "Working directory is not a directory"); String topDirectoryName = workingDir.getFileName().toString(); switch (topDirectoryName) { case "presto-benchto-benchmarks": return workingDir; case "presto": return workingDir.resolve("presto-benchto-benchmarks"); default: throw new IllegalStateException("This class must be executed from presto-benchto-benchmarks or presto source directory"); } }
@Override public boolean accept(Path entry) throws IOException { return Files.isDirectory(entry) || matchPattern.matcher(entry.getFileName().toString()).matches(); } }
private static IVersionInfo getFromClasspath(List<String> classpath, final String propFileName) { IVersionInfo ret = null; for (String part: classpath) { Path p = Paths.get(part); if (Files.isDirectory(p)) { Path child = p.resolve(propFileName); if (Files.exists(child) && !Files.isDirectory(child)) { try (FileReader reader = new FileReader(child.toFile())) { Properties info = new Properties();
public void processEvent(BiConsumer<WatchEvent.Kind<Path>, Path> processor){ for(;;){ WatchKey key; try{ key = watcher.take(); }catch (InterruptedException e) { return; } Path dir = pathMap.get(key); for (WatchEvent<?> event: key.pollEvents()){ WatchEvent.Kind kind = event.kind(); Path filePath = dir.resolve(((WatchEvent<Path>)event).context()); if(Files.isDirectory(filePath)) continue; log.info("File {} changes detected!",filePath.toString()); //copy updated files to target processor.accept(kind, filePath); } key.reset(); } }
Path logFolder = config.getHomeDir().resolve("logs"); if (!Files.isDirectory(logFolder)) { Files.createDirectories(logFolder); Path file = logFolder.resolve("bimserver.log"); ple.start(); FileAppender<ILoggingEvent> fileAppender = new FileAppender<ILoggingEvent>(); String filename = file.toAbsolutePath().toString();
private void handleItemSelection(String item) { Path path = currentPath == null ? Paths.get(item) : currentPath.resolve(item); if (Files.isDirectory(path)) { setCurrentDirectory(path); } else { fileName = item; } }
/** * Answers if the given path denotes existing directory. * * @param path The directory path. * @return {@code True} if the given path denotes an existing directory. */ public static boolean exists(String path) { if (F.isEmpty(path)) return false; Path p = Paths.get(path); return Files.exists(p) && Files.isDirectory(p) && Files.isReadable(p); }
public RuleDocGenerator(FileWriter writer, Path root) { this.writer = Objects.requireNonNull(writer, "A file writer must be provided"); this.root = Objects.requireNonNull(root, "Root directory must be provided"); Path docsDir = root.resolve("docs"); if (!Files.exists(docsDir) || !Files.isDirectory(docsDir)) { throw new IllegalArgumentException("Couldn't find \"docs\" subdirectory"); } }
final Path tmpPath = Paths.get(tmpDir); if (!Files.isDirectory(tmpPath) || !Files.isWritable(tmpPath)) { throw new IllegalStateException("Couldn't write to temporary directory: " + tmpPath.toAbsolutePath());
FileSystemHttpVfs(Path rootDir) { this.rootDir = requireNonNull(rootDir, "rootDir").toAbsolutePath(); if (!Files.exists(this.rootDir) || !Files.isDirectory(this.rootDir)) { throw new IllegalArgumentException("rootDir: " + rootDir + " (not a directory"); } }
if (!Files.exists(jar)) { System.err.println(jar + " is not exists"); usage(); if (Files.isDirectory(jar)) { output = new File(jar.getFileName() + "-jar2dex.dex").toPath(); } else { output = new File(getBaseName(jar.getFileName().toString()) + "-jar2dex.dex").toPath(); if (Files.exists(output) && !forceOverwrite) { System.err.println(output + " exists, use --force to overwrite"); usage(); final Path realJar; try { if (Files.isDirectory(jar)) { realJar = Files.createTempFile("d2j", ".jar"); tmp = realJar; ps.addAll(Arrays.asList("--dex", "--no-strict", "--output=" + output.toAbsolutePath().toString(), realJar .toAbsolutePath().toString())); System.out.println("call com.android.dx.command.Main.main" + ps); m.invoke(null, new Object[] { ps.toArray(new String[ps.size()]) });
/** * Creates a new local Alluxio master with a isolated port. * * @param workDirectory Alluxio work directory, this method will create it if it doesn't exist yet * @return the created Alluxio master */ public static LocalAlluxioMaster create(final String workDirectory) throws IOException { if (!Files.isDirectory(Paths.get(workDirectory))) { Files.createDirectory(Paths.get(workDirectory)); } return new LocalAlluxioMaster(null, null); }
if (!Files.exists(jar)) { System.err.println(jar + " is not exists"); usage(); if (Files.isDirectory(jar)) { output = new File(jar.getFileName() + "-rechecksum.dex").toPath(); } else { output = new File(getBaseName(jar.getFileName().toString()) + "-rechecksum.dex").toPath(); if (Files.exists(output) && !forceOverwrite) { System.err.println(output + " exists, use --force to overwrite"); usage();
Path outdir = this.basedir.toPath().resolve("node_modules").resolve(library.replace("/", ".")); Optional<Path> basedir = Try.apply(() -> Paths.get(uri)).toOptional(); String libroot = Route.normalize("/" + library); try (Library lib = loadLibrary(uri)) { try (Stream<Path> stream = lib.stream()) { stream.filter(it -> !Files.isDirectory(it)) .forEach(it -> { String relative = basedir.map(d -> d.relativize(it).toString()) .orElseGet(() -> { String fname = it.toString(); if (fname.startsWith(libroot)) { fname = fname.substring(libroot.length()); Path output = outdir.resolve(relative); File fout = output.toFile(); boolean copy = !fout.exists()