hudson.FilePath.isDirectory()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(233)

本文整理了Java中hudson.FilePath.isDirectory()方法的一些代码示例,展示了FilePath.isDirectory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FilePath.isDirectory()方法的具体详情如下:
包路径:hudson.FilePath
类名称:FilePath
方法名:isDirectory

FilePath.isDirectory介绍

[英]Checks if the file is a directory.
[中]检查文件是否为目录。

代码示例

代码示例来源:origin: jenkinsci/jenkins

@Override public boolean isDirectory() throws IOException {
  try {
    return f.isDirectory();
  } catch (InterruptedException x) {
    throw new IOException(x);
  }
}
@Override public boolean isFile() throws IOException {

代码示例来源:origin: jenkinsci/jenkins

if(children.get(0).isDirectory())
  return children.get(0);
return null;

代码示例来源:origin: jenkinsci/jenkins

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

代码示例来源:origin: jenkinsci/jenkins

if(!ws.child(value).isDirectory())
    ok();
  else
    error(value+" is not a file");
} else {
  if(ws.child(value).isDirectory())
    ok();
  else

代码示例来源:origin: jenkinsci/shiningpanda-plugin

/**
 * 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();
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

@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 {

代码示例来源:origin: jenkinsci/shiningpanda-plugin

/**
 * 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();
}

代码示例来源:origin: jenkinsci/artifactory-plugin

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()));
  }
}

代码示例来源:origin: jenkinsci/pipeline-aws-plugin

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()
  );
}

代码示例来源:origin: jenkinsci/pipeline-utility-steps-plugin

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());
}

代码示例来源:origin: org.jenkins-ci.plugins/pipeline-utility-steps

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());
}

代码示例来源:origin: awslabs/aws-codedeploy-plugin

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;
}

代码示例来源:origin: jenkinsci/performance-plugin

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;
}

代码示例来源:origin: org.jenkins-ci.plugins/vectorcast-coverage

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];
  }
}

代码示例来源:origin: org.jenkins-ci.plugins/pipeline-utility-steps

protected FileWrapper(@Nonnull FilePath file) throws IOException, InterruptedException {
  this(file.getName(), file.getRemote(), file.isDirectory(), file.length(), file.lastModified());
}

代码示例来源:origin: jenkinsci/pipeline-utility-steps-plugin

protected FileWrapper(@Nonnull FilePath file) throws IOException, InterruptedException {
  this(file.getName(), file.getRemote(), file.isDirectory(), file.length(), file.lastModified());
}

代码示例来源:origin: jenkinsci/marathon-plugin

@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;
}

代码示例来源:origin: jenkinsci/marathon-plugin

@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;
}

代码示例来源:origin: org.jenkins-ci.plugins/pipeline-utility-steps

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));
}

代码示例来源:origin: org.jenkins-ci.plugins.workflow/workflow-cps-global-lib

@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"));
    }
  }
}

相关文章