io.fabric8.utils.Files.getRelativePath()方法的使用及代码示例

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

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

Files.getRelativePath介绍

暂无

代码示例

代码示例来源:origin: io.fabric8/fabric8-project-utils

public static String getFilePattern(File rootDir, File file) throws IOException {
  String relativePath = Files.getRelativePath(rootDir, file);
  if (relativePath.startsWith(File.separator)) {
    relativePath = relativePath.substring(1);
  }
  return relativePath.replace(File.separatorChar, '/');
}

代码示例来源:origin: io.fabric8.devops.apps/git-collector

public static String getFilePattern(File rootDir, File file) throws IOException {
  String relativePath = Files.getRelativePath(rootDir, file);
  if (relativePath.startsWith(File.separator)) {
    relativePath = relativePath.substring(1);
  }
  return relativePath.replace(File.separatorChar, '/');
}

代码示例来源:origin: io.fabric8.forge/rest-core

private String getFilePattern(File rootDir, File file) throws IOException {
  String relativePath = Files.getRelativePath(rootDir, file);
  if (relativePath.startsWith(File.separator)) {
    relativePath = relativePath.substring(1);
  }
  return relativePath.replace(File.separatorChar, '/');
}

代码示例来源:origin: io.jenkins.updatebot/updatebot-core

public static Object getRelativePathToCurrentDir(File dir) {
  File currentDir = new File(System.getProperty("user.dir", "."));
  try {
    String relativePath = Files.getRelativePath(currentDir, dir);
    if (relativePath.startsWith("/")) {
      return relativePath.substring(1);
    }
    return relativePath;
  } catch (IOException e) {
    return dir;
  }
}

代码示例来源:origin: io.fabric8.updatebot/updatebot-core

public static Object getRelativePathToCurrentDir(File dir) {
  File currentDir = new File(System.getProperty("user.dir", "."));
  try {
    String relativePath = Files.getRelativePath(currentDir, dir);
    if (relativePath.startsWith("/")) {
      return relativePath.substring(1);
    }
    return relativePath;
  } catch (IOException e) {
    return dir;
  }
}

代码示例来源:origin: fabric8io/jube

/**
 * Adds a modified or deleted file as a reason for restarting an installation
 */
public void addRestartReason(File target) {
  String path = null;
  try {
    path = Files.getRelativePath(installDir, target);
  } catch (IOException e) {
    LOG.warn("Failed to calculate relative path from " + installDir + " to " + target + ". " + e, e);
  }
  if (path == null) {
    path = target.getPath();
  }
  addRestartReason(path);
}

代码示例来源:origin: io.fabric8.forge/funktion

private String findSingleFileInDirectory(File baseDir, String directoryPath, String... extensions) {
  File dir = baseDir;
  if (!Strings.isNullOrEmpty(directoryPath)) {
    dir = new File(baseDir, directoryPath);
  }
  if (dir.isDirectory()) {
    File[] files = dir.listFiles();
    if (files != null) {
      for (File file : files) {
        for (String extension : extensions) {
          if (file.getName().endsWith(extension)) {
            try {
              return Files.getRelativePath(baseDir, file);
            } catch (IOException e) {
              LOG.warn("Failed to calculate relative path of " + file + ". " + e, e);
            }
          }
        }
      }
      System.out.println("No files with extensions " + Arrays.asList(extensions) + " for files: " + Arrays.asList(files));
    } else {
      System.out.println("No files in directory: " + dir.getAbsolutePath());
    }
  } else {
    System.out.println("Not a direcotry: " + dir.getAbsolutePath());
  }
  return null;
}

代码示例来源:origin: io.fabric8.forge/fabric8-forge-core

protected FileDTO createFileDTO(File file, boolean includeContent) {
  File parentFile = file.getParentFile();
  String relativePath = null;
  try {
    relativePath = trimLeadingSlash(Files.getRelativePath(basedir, parentFile));
  } catch (IOException e) {
    LOG.warn("Failed to find relative path of " + parentFile.getPath() + ". " + e, e);
  }
  FileDTO answer = FileDTO.createFileDTO(file, relativePath, includeContent, "", false);
  String path = answer.getPath();
  if (path.equals(".git")) {
    // lets ignore the git folder!
    return null;
  }
  // TODO use the path to generate the links...
  // TODO generate the SHA
  return answer;
}

代码示例来源:origin: io.jenkins.updatebot/updatebot-core

private void addMatchFiles(List<File> answer, File rootDir, File file) throws IOException {
  if (file.isDirectory()) {
    File[] children = file.listFiles();
    if (children != null) {
      for (File child : children) {
        addMatchFiles(answer, rootDir, child);
      }
    }
  } else {
    String path = Files.getRelativePath(rootDir, file);
    path = Strings.trimAllPrefix(path, File.separator);
    if (matchesPatterns(path, includes) && !matchesPatterns(path, excludes)) {
      answer.add(file);
    }
  }
}

代码示例来源:origin: io.fabric8.updatebot/updatebot-core

private void addMatchFiles(List<File> answer, File rootDir, File file) throws IOException {
  if (file.isDirectory()) {
    File[] children = file.listFiles();
    if (children != null) {
      for (File child : children) {
        addMatchFiles(answer, rootDir, child);
      }
    }
  } else {
    String path = Files.getRelativePath(rootDir, file);
    path = Strings.trimAllPrefix(path, "/");
    if (matchesPatterns(path, includes) && !matchesPatterns(path, excludes)) {
      answer.add(file);
    }
  }
}

代码示例来源:origin: io.fabric8.forge/devops

for (File file : files) {
  try {
    String relativePath = Files.getRelativePath(dir, file);
    String value = Strings.stripPrefix(relativePath, "/");
    String label = value;

代码示例来源:origin: io.fabric8/fabric8-maven-enricher-fabric8

File rootProjectFolder = getRootProjectFolder();
if (rootProjectFolder != null) {
  String relativePath = Files.getRelativePath(rootProjectFolder, iconSourceFile);
  String relativeParentPath = Files.getRelativePath(rootProjectFolder, getProject().getBasedir());
  String urlPrefix = getConfig(Config.urlPrefix);
  if (Strings.isNullOrBlank(urlPrefix)) {

代码示例来源:origin: io.fabric8.updatebot/updatebot-core

String relativePath = Files.getRelativePath(jenkinsLibraryDir, jenkinsfile);
configuration.info(LOG, "Adding Jenkinsfile " + Strings.trimAllPrefix(relativePath, "/"));
File dir = context.getDir();

代码示例来源:origin: io.jenkins.updatebot/updatebot-core

String relativePath = Files.getRelativePath(jenkinsLibraryDir, jenkinsfile);
configuration.info(LOG, "Adding Jenkinsfile " + Strings.trimAllPrefix(relativePath, "/"));
File dir = context.getDir();

相关文章