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, '/'); }
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, '/'); }
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, '/'); }
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; } }
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; } }
/** * 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); }
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; }
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; }
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); } } }
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); } } }
for (File file : files) { try { String relativePath = Files.getRelativePath(dir, file); String value = Strings.stripPrefix(relativePath, "/"); String label = value;
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)) {
String relativePath = Files.getRelativePath(jenkinsLibraryDir, jenkinsfile); configuration.info(LOG, "Adding Jenkinsfile " + Strings.trimAllPrefix(relativePath, "/")); File dir = context.getDir();
String relativePath = Files.getRelativePath(jenkinsLibraryDir, jenkinsfile); configuration.info(LOG, "Adding Jenkinsfile " + Strings.trimAllPrefix(relativePath, "/")); File dir = context.getDir();