/** * Get {@link Path} of the directory. * @param type Type of the directory * @return Path * @since TODO * @throws IOException Invalid path, e.g. ig the root directory is incorrect */ @CheckForNull public Path getLocationPath(@Nonnull DirType type) throws IOException { File location = directories.get(type); return location != null ? PathUtils.fileToPath(location) : null; }
/** * @deprecated Use {@link Files#createDirectories(java.nio.file.Path, java.nio.file.attribute.FileAttribute...)} instead. */ @Deprecated static void mkdirs(@Nonnull File file) throws IOException { if (file.isDirectory()) return; Files.createDirectories(PathUtils.fileToPath(file)); }
@Nonnull static File makeResource(String name, byte[] image) throws IOException { Path tmpDir = Files.createTempDirectory("resource-"); File resource = new File(tmpDir.toFile(), name); Files.createDirectories(PathUtils.fileToPath(resource.getParentFile())); Files.createFile(PathUtils.fileToPath(resource)); try(FileOutputStream fos = new FileOutputStream(resource)) { fos.write(image); } deleteDirectoryOnExit(resource); return resource; }
private void createInternalDirIfRequired(File internalDir, DirType type) throws IOException { if (!disabledDirectories.contains(type)) { final File directory = new File(internalDir, type.getDefaultLocation()); verifyDirectory(directory, type, false); Files.createDirectories(PathUtils.fileToPath(directory)); directories.put(type, directory); } else { LOGGER.log(Level.FINE, "Skipping the disabled directory: {0}", type.getName()); } }
@Override protected URL lookInCache(Channel channel, long sum1, long sum2) throws IOException, InterruptedException { File jar = map(sum1, sum2); if (jar.exists()) { LOGGER.log(Level.FINER, String.format("Jar file cache hit %16X%16X",sum1,sum2)); if (touch) { Files.setLastModifiedTime(PathUtils.fileToPath(jar), FileTime.fromMillis(System.currentTimeMillis())); } if (notified.add(new Checksum(sum1,sum2))) { getJarLoader(channel).notifyJarPresence(sum1,sum2); } return jar.toURI().toURL(); } return null; }
final Path internalDirPath = PathUtils.fileToPath(internalDirFile); Files.createDirectories(internalDirPath); LOGGER.log(Level.INFO, "Using {0} as a remoting work directory", internalDirPath);
target.getAbsolutePath(), expected, actual )); Files.delete(PathUtils.fileToPath(target)); synchronized (checksumsByPath) { checksumsByPath.remove(target.getCanonicalPath()); Files.deleteIfExists(PathUtils.fileToPath(tmp));
workDirManager.disable(WorkDirManager.DirType.LOGS_DIR); workDirManager.setupLogging(internalDirPath, slaveLog != null ? PathUtils.fileToPath(slaveLog) : null);
engine.setAgentLog(PathUtils.fileToPath(agentLog)); } catch (IOException ex) { throw new IllegalStateException("Cannot retrieve custom log destination", ex); engine.setLoggingConfigFile(PathUtils.fileToPath(loggingConfigFile)); } catch (IOException ex) { throw new IllegalStateException("Logging config file is invalid", ex); engine.setWorkDir(PathUtils.fileToPath(workDir)); } catch (IOException ex) { throw new IllegalStateException("Work directory path is invalid", ex);