@Override public boolean isDirectory() throws IOException { try { return f.isDirectory(); } catch (InterruptedException x) { throw new IOException(x); } } @Override public boolean isFile() throws IOException {
if(children.get(0).isDirectory()) return children.get(0); return null;
if(path.exists()) { if (expectingFile) { if(!path.isDirectory()) return FormValidation.ok(); else return FormValidation.error(Messages.FilePath_validateRelativePath_notFile(value)); } else { if(path.isDirectory()) return FormValidation.ok(); else
if(!ws.child(value).isDirectory()) ok(); else error(value+" is not a file"); } else { if(ws.child(value).isDirectory()) ok(); else
/** * Check if the provided path is a directory * * @param filePath * The path to check * @return true if this is a directory, else false * @throws IOException * @throws InterruptedException */ public static boolean isDirectory(FilePath filePath) throws IOException, InterruptedException { return filePath != null && filePath.isDirectory(); }
@Override public boolean isDirectory() throws IOException { try { return f.isDirectory(); } catch (InterruptedException x) { throw (IOException) new IOException(x.toString()).initCause(x); } } @Override public boolean isFile() throws IOException {
/** * Check if the provided path is a file * * @param filePath * The file to check * @return true if this is a file, else false * @throws IOException * @throws InterruptedException */ public static boolean isFile(FilePath filePath) throws IOException, InterruptedException { return filePath != null && filePath.exists() && !filePath.isDirectory(); }
private static FilePath buildDownloadSpecPath(String providedPath, FilePath workingDir, PrintStream logger) throws IOException, InterruptedException { FilePath relativeFile = new FilePath(workingDir, providedPath); if (relativeFile.exists() && !relativeFile.isDirectory()) { logger.println(String.format("Using spec file: %s", relativeFile.getRemote())); return relativeFile; } throw new IOException(String.format("Could not find spec file in the provided path: %s", relativeFile.getRemote())); } }
protected FileWrapper(@Nonnull FilePath base, @Nonnull FilePath file) throws IOException, InterruptedException { this(file.getName(), file.getRemote().substring(base.getRemote().length() + 1), file.isDirectory(), file.length(), file.lastModified() ); }
protected FileWrapper(@Nonnull FilePath base, @Nonnull FilePath file) throws IOException, InterruptedException { this(file.getName(), file.getRemote().substring(base.getRemote().length() + 1), file.isDirectory(), file.length(), file.lastModified()); }
protected FileWrapper(@Nonnull FilePath base, @Nonnull FilePath file) throws IOException, InterruptedException { this(file.getName(), file.getRemote().substring(base.getRemote().length() + 1), file.isDirectory(), file.length(), file.lastModified()); }
private FilePath getSourceDirectory(FilePath basePath) throws IOException, InterruptedException { String subdirectory = StringUtils.trimToEmpty(getSubdirectoryFromEnv()); if (!subdirectory.isEmpty() && !subdirectory.startsWith("/")) { subdirectory = "/" + subdirectory; } FilePath sourcePath = basePath.withSuffix(subdirectory).absolutize(); if (!sourcePath.isDirectory() || !isSubDirectory(basePath, sourcePath)) { throw new IllegalArgumentException("Provided path (resolved as '" + sourcePath +"') is not a subdirectory of the workspace (resolved as '" + basePath + "')"); } return sourcePath; }
private List<File> copyReportsToMaster(Run<?, ?> build, PrintStream logger, List<FilePath> files, String parserDisplayName) throws IOException, InterruptedException { List<File> localReports = new ArrayList<File>(); for (FilePath src : files) { final File localReport = getPerformanceReport(build, parserDisplayName, src.getName()); if (src.isDirectory()) { logger.println("Performance: File '" + src.getName() + "' is a directory, not a Performance Report"); continue; } src.copyTo(new FilePath(localReport)); localReports.add(localReport); } return localReports; }
protected static FilePath[] getVectorCASTCoverageReports(File file) throws IOException, InterruptedException { FilePath path = new FilePath(file); if (path.isDirectory()) { return path.list("*xml"); } else { // Read old builds (before 1.11) FilePath report = new FilePath(new File(path.getName() + ".xml")); return report.exists() ? new FilePath[]{report} : new FilePath[0]; } }
protected FileWrapper(@Nonnull FilePath file) throws IOException, InterruptedException { this(file.getName(), file.getRemote(), file.isDirectory(), file.length(), file.lastModified()); }
protected FileWrapper(@Nonnull FilePath file) throws IOException, InterruptedException { this(file.getName(), file.getRemote(), file.isDirectory(), file.length(), file.lastModified()); }
@Override public MarathonBuilder toFile(final String filename) throws InterruptedException, IOException, MarathonFileInvalidException { final String realFilename = filename != null ? filename : MarathonBuilderUtils.MARATHON_RENDERED_JSON; final FilePath renderedFilepath = workspace.child(Util.replaceMacro(realFilename, envVars)); if (renderedFilepath.exists() && renderedFilepath.isDirectory()) throw new MarathonFileInvalidException("File '" + realFilename + "' is a directory; not overwriting."); renderedFilepath.write(json.toString(), null); return this; }
@Override public MarathonBuilder read(final String filename) throws IOException, InterruptedException, MarathonFileMissingException, MarathonFileInvalidException { final String realFilename = filename != null ? filename : MarathonBuilderUtils.MARATHON_JSON; final FilePath marathonFile = workspace.child(realFilename); if (!marathonFile.exists()) { throw new MarathonFileMissingException(realFilename); } else if (marathonFile.isDirectory()) { throw new MarathonFileInvalidException("File '" + realFilename + "' is a directory."); } final String content = marathonFile.readToString(); this.json = JSONObject.fromObject(content); return this; }
private Boolean test() throws IOException, InterruptedException { FilePath source = ws.child(step.getZipFile()); if (!source.exists()) { listener.error(source.getRemote() + " does not exist."); return false; } else if (source.isDirectory()) { listener.error(source.getRemote() + " is a directory."); return false; } return source.act(new TestZipFileCallable(listener)); }
@Override public void copy(Run<?,?> original, Run<?,?> copy, TaskListener listener) throws IOException, InterruptedException { LibrariesAction action = original.getAction(LibrariesAction.class); if (action != null) { copy.addAction(new LibrariesAction(action.getLibraries())); FilePath libs = new FilePath(original.getRootDir()).child("libs"); if (libs.isDirectory()) { libs.copyRecursiveTo(new FilePath(copy.getRootDir()).child("libs")); } } }