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

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

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

FilePath.isAbsolute介绍

[英]Is the given path name an absolute path?
[中]给定的路径名是绝对路径吗?

代码示例

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

private String resolvePathIfRelative(@Nonnull FilePath base, @Nonnull String rel) {
  if(isAbsolute(rel)) return rel;
  if(base.isUnix()) {
    // shouldn't need this replace, but better safe than sorry
    return base.remote+'/'+rel.replace('\\','/');
  } else {
    // need this replace, see Slave.getWorkspaceFor and AbstractItem.getFullName, nested jobs on Windows
    // agents will always have a rel containing at least one '/' character. JENKINS-13649
    return base.remote+'\\'+rel.replace('/','\\');
  }
}

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

/**
 * Runs Ant glob expansion.
 *
 * @return
 *      A set of relative file names from the base directory.
 */
@Nonnull
private static String[] glob(File dir, String includes, String excludes, boolean defaultExcludes) throws IOException {
  if(isAbsolute(includes))
    throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax");
  FileSet fs = Util.createFileSet(dir,includes,excludes);
  fs.setDefaultexcludes(defaultExcludes);
  DirectoryScanner ds;
  try {
    ds = fs.getDirectoryScanner(new Project());
  } catch (BuildException x) {
    throw new IOException(x.getMessage());
  }
  String[] files = ds.getIncludedFiles();
  return files;
}

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

private String resolvePathIfRelative(@Nonnull FilePath base, @Nonnull String rel) {
  if(isAbsolute(rel)) return rel;
  if(base.isUnix()) {
    // shouldn't need this replace, but better safe than sorry
    return base.remote+'/'+rel.replace('\\','/');
  } else {
    // need this replace, see Slave.getWorkspaceFor and AbstractItem.getFullName, nested jobs on Windows
    // agents will always have a rel containing at least one '/' character. JENKINS-13649
    return base.remote+'\\'+rel.replace('/','\\');
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Runs Ant glob expansion.
 *
 * @return
 *      A set of relative file names from the base directory.
 */
private static String[] glob(File dir, String includes, String excludes) throws IOException {
  if(isAbsolute(includes))
    throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax");
  FileSet fs = Util.createFileSet(dir,includes,excludes);
  DirectoryScanner ds = fs.getDirectoryScanner(new Project());
  String[] files = ds.getIncludedFiles();
  return files;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Runs Ant glob expansion.
 *
 * @return
 *      A set of relative file names from the base directory.
 */
private static String[] glob(File dir, String includes) throws IOException {
  if(isAbsolute(includes))
    throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax");
  FileSet fs = Util.createFileSet(dir,includes);
  DirectoryScanner ds = fs.getDirectoryScanner(new Project());
  String[] files = ds.getIncludedFiles();
  return files;
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Runs Ant glob expansion.
 *
 * @return
 *      A set of relative file names from the base directory.
 */
private static String[] glob(File dir, String includes) throws IOException {
  if(isAbsolute(includes))
    throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax");
  FileSet fs = Util.createFileSet(dir,includes);
  DirectoryScanner ds = fs.getDirectoryScanner(new Project());
  String[] files = ds.getIncludedFiles();
  return files;
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Runs Ant glob expansion.
 *
 * @return
 *      A set of relative file names from the base directory.
 */
private static String[] glob(File dir, String includes) throws IOException {
  if(isAbsolute(includes))
    throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax");
  FileSet fs = Util.createFileSet(dir,includes);
  DirectoryScanner ds = fs.getDirectoryScanner(new Project());
  String[] files = ds.getIncludedFiles();
  return files;
}

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

/**
 * Runs Ant glob expansion.
 *
 * @return
 *      A set of relative file names from the base directory.
 */
@Nonnull
private static String[] glob(File dir, String includes, String excludes, boolean defaultExcludes) throws IOException {
  if(isAbsolute(includes))
    throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax");
  FileSet fs = Util.createFileSet(dir,includes,excludes);
  fs.setDefaultexcludes(defaultExcludes);
  DirectoryScanner ds = fs.getDirectoryScanner(new Project());
  String[] files = ds.getIncludedFiles();
  return files;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Construct a path starting with a base location.
 * @param base starting point for resolution, and defines channel
 * @param rel a path which if relative will be resolved against base
 */
public FilePath(FilePath base, String rel) {
  this.channel = base.channel;
  if(isAbsolute(rel)) {
    // absolute
    this.remote = normalize(rel);
  } else 
  if(base.isUnix()) {
    this.remote = normalize(base.remote+'/'+rel);
  } else {
    //Normalize rel path for windows environment. See http://issues.hudson-ci.org/browse/HUDSON-5084
    this.remote = normalize(base.remote+'\\'+ StringUtils.replace(rel, "/", "\\"));
  }
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Construct a path starting with a base location.
 *
 * @param base starting point for resolution, and defines channel
 * @param rel a path which if relative will be resolved against base
 */
public FilePath(FilePath base, String rel) {
  this.channel = base.channel;
  if (isAbsolute(rel)) {
    // absolute
    this.remote = normalize(rel);
  } else if (base.isUnix()) {
    this.remote = normalize(base.remote + '/' + rel);
  } else {
    //Normalize rel path for windows environment. See http://issues.hudson-ci.org/browse/HUDSON-5084
    this.remote = normalize(base.remote + '\\' + StringUtils.replace(rel, "/", "\\"));
  }
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Construct a path starting with a base location.
 * @param base starting point for resolution, and defines channel
 * @param rel a path which if relative will be resolved against base
 */
public FilePath(FilePath base, String rel) {
  this.channel = base.channel;
  if(isAbsolute(rel)) {
    // absolute
    this.remote = normalize(rel);
  } else 
  if(base.isUnix()) {
    this.remote = normalize(base.remote+'/'+rel);
  } else {
    //Normalize rel path for windows environment. See http://issues.hudson-ci.org/browse/HUDSON-5084
    this.remote = normalize(base.remote+'\\'+ StringUtils.replace(rel, "/", "\\"));
  }
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Construct a path starting with a base location.
 * @param base starting point for resolution, and defines channel
 * @param rel a path which if relative will be resolved against base
 */
public FilePath(FilePath base, String rel) {
  this.channel = base.channel;
  if(isAbsolute(rel)) {
    // absolute
    this.remote = normalize(rel);
  } else 
  if(base.isUnix()) {
    this.remote = normalize(base.remote+'/'+rel);
  } else {
    //Normalize rel path for windows environment. See http://issues.hudson-ci.org/browse/HUDSON-5084
    this.remote = normalize(base.remote+'\\'+ StringUtils.replace(rel, "/", "\\"));
  }
}

相关文章