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

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

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

FilePath.getName介绍

[英]Gets just the file name portion. This method assumes that the file name is the same between local and remote.
[中]仅获取文件名部分。此方法假定本地和远程之间的文件名相同。

代码示例

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

@Override public String getName() {
  return f.getName();
}
@Override public URI toURI() {

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

/**
 * Gets the file name portion except the extension.
 *
 * For example, "foo" for "foo.txt" and "foo.tar" for "foo.tar.gz".
 */
public String getBaseName() {
  String n = getName();
  int idx = n.lastIndexOf('.');
  if (idx<0)  return n;
  return n.substring(0,idx);
}
/**

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

@Override
public Void invoke(File dir, VirtualChannel channel) throws IOException, InterruptedException {
  readFromTar(FilePath.this.getName(), dir, compression.extract(in));
  return null;
}
private static final long serialVersionUID = 1L;

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

/**
 * Locates a conventional temporary directory to be associated with a workspace.
 * <p>This directory is suitable for temporary files to be deleted later in the course of a build,
 * or caches and local repositories which should persist across builds done in the same workspace.
 * (If multiple workspaces are present for a single job built concurrently, via {@link #allocate(FilePath)}, each will get its own temporary directory.)
 * <p>It may also be used for security-sensitive files which {@link DirectoryBrowserSupport} ought not serve,
 * acknowledging that these will be readable by builds of other jobs done on the same node.
 * <p>Each plugin using this directory is responsible for specifying sufficiently unique subdirectory/file names.
 * {@link FilePath#createTempFile} may be used for this purpose if desired.
 * <p>The resulting directory may not exist; you may call {@link FilePath#mkdirs} on it if you need it to.
 * It may be deleted alongside the workspace itself during cleanup actions.
 * @param ws a directory such as a build workspace
 * @return a sibling directory, for example {@code …/something@tmp} for {@code …/something}
 * @since 1.652
 */
public static FilePath tempDir(FilePath ws) {
  return ws.sibling(ws.getName() + COMBINATOR + "tmp");
}

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

@Override
public Void invoke(File dir, VirtualChannel channel) throws IOException, InterruptedException {
  readFromTar(FilePath.this.getName(), dir, compression.extract(FilePath.this.read()));
  return null;
}
private static final long serialVersionUID = 1L;

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

/**
   * To be kept in sync with {@link FileVF#computeRelativePathToRoot()}
   */
  private String computeRelativePathToRoot(){
    if (this.root.equals(this.f)) {
      return "";
    }
    LinkedList<String> relativePath = new LinkedList<>();
    FilePath current = this.f;
    while (current != null && !current.equals(this.root)) {
      relativePath.addFirst(current.getName());
      current = current.getParent();
    }
    return String.join(File.separator, relativePath) + File.separator;
  }
}

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

@SuppressWarnings("deprecation")
  @Override
  public ParameterValue createValue(CLICommand command, String value) throws IOException, InterruptedException {
    // capture the file to the server
    File local = File.createTempFile("jenkins","parameter");
    String name;
    if (value.isEmpty()) {
      FileUtils.copyInputStreamToFile(command.stdin, local);
      name = "stdin";
    } else {
      FilePath src = new FilePath(command.checkChannel(), value);
      src.copyTo(new FilePath(local));
      name = src.getName();
    }

    FileParameterValue p = new FileParameterValue(getName(), local, name);
    p.setDescription(getDescription());
    p.setLocation(getName());
    return p;
  }
}

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

/**
 * Gets the file name portion except the extension.
 *
 * For example, "foo" for "foo.txt" and "foo.tar" for "foo.tar.gz".
 */
public String getBaseName() {
  String n = getName();
  int idx = n.lastIndexOf('.');
  if (idx<0)  return n;
  return n.substring(0,idx);
}
/**

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

/**
 * Gets the file name portion except the extension.
 *
 * For example, "foo" for "foo.txt" and "foo.tar" for "foo.tar.gz".
 */
public String getBaseName() {
  String n = getName();
  int idx = n.lastIndexOf('.');
  if (idx<0)  return n;
  return n.substring(0,idx);
}
/**

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

/**
 * @return the local path to the uploaded file.
 */
private String getLocalFilePath(FilePath workspace, 
                FilePath uploadFilePath) {
  String path = this.getRelativePath(workspace, uploadFilePath) +
    uploadFilePath.getName();
  if (path.startsWith("/")) {
    path = path.replaceFirst("/", "");
  }
  return path;
}

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

public List<String> listSubDirectories(String dir) throws IOException, InterruptedException {
  List<String> r = new ArrayList<String>();
  for( FilePath f : $(dir).listDirectories())
    r.add(f.getName());
  return r;
}

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

public List<String> listSubDirectories(String dir) throws IOException, InterruptedException {
  List<String> r = new ArrayList<String>();
  for( FilePath f : $(dir).listDirectories())
    r.add(f.getName());
  return r;
}

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

@Override
public List<String> listSubDirectories(String dir) throws IOException, InterruptedException {
  List<String> r = new ArrayList<String>();
  for (FilePath f : $(dir).listDirectories()) {
    r.add(f.getName());
  }
  return r;
}

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

public Void invoke(File dir, VirtualChannel channel) throws IOException, InterruptedException {
  readFromTar(FilePath.this.getName(),dir,compression.extract(FilePath.this.read()));
  return null;
}
private static final long serialVersionUID = 1L;

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

public Void invoke(File dir, VirtualChannel channel) throws IOException {
  readFromTar(FilePath.this.getName(), dir, compression.extract(FilePath.this.read()), nativeUtils);
  return null;
}
private static final long serialVersionUID = 1L;

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

public Void invoke(File dir, VirtualChannel channel) throws IOException {
  readFromTar(FilePath.this.getName(),dir,compression.extract(FilePath.this.read()));
  return null;
}
private static final long serialVersionUID = 1L;

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

public Void invoke(File dir, VirtualChannel channel) throws IOException {
  readFromTar(FilePath.this.getName(),dir,compression.extract(FilePath.this.read()));
  return null;
}
private static final long serialVersionUID = 1L;

代码示例来源: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.eclipse.hudson/hudson-core

@Override
  public ParameterValue createValue(CLICommand command, String value) throws IOException, InterruptedException {
    // capture the file to the server
    FilePath src = new FilePath(command.channel, value);
    File local = File.createTempFile("hudson", "parameter");
    src.copyTo(new FilePath(local));

    FileParameterValue p = new FileParameterValue(getName(), local, src.getName());
    p.setDescription(getDescription());
    p.setLocation(getName());
    return p;
  }
}

相关文章