public WildcardScanner(File rootPath, String pattern) { this.rootPath = rootPath; this.pattern = FilenameUtils.separatorsToUnix(pattern); }
@Override public String getDestination() { return StringUtils.isBlank(destination) ? TEST_OUTPUT_FOLDER : FilenameUtils.separatorsToUnix(destination); } }
protected File valueOf(String text) { if (text == null) { return null; } return new File(FilenameUtils.separatorsToUnix(text)); } }
public static String subtractPath(File rootPath, File file) { String fullPath = FilenameUtils.separatorsToUnix(file.getParentFile().getPath()); String basePath = FilenameUtils.separatorsToUnix(rootPath.getPath()); return StringUtils.removeStart(StringUtils.removeStart(fullPath, basePath), "/"); }
@Override public String getDestination() { return StringUtils.isBlank(destination) ? DEFAULT_ROOT.getPath() : FilenameUtils.separatorsToUnix(destination); }
private String removeLeadingSlash(File artifactDest) { return removeStart(FilenameUtils.separatorsToUnix(artifactDest.getPath()), "/"); } }
public String arguments() { ArrayList<String> args = new ArrayList<>(); if (buildFile != null) { args.add("-f \"" + FilenameUtils.separatorsToUnix(buildFile) + "\""); } if (target != null) { args.add(target); } return StringUtils.join(args, " "); }
public String arguments() { ArrayList<String> args = new ArrayList<>(); if (buildFile != null) { args.add("-buildfile:\"" + FilenameUtils.separatorsToUnix(buildFile) + "\""); } if (target != null) { args.add(target); } return StringUtils.join(args, " "); }
public String arguments() { ArrayList<String> args = new ArrayList<>(); if (buildFile != null) { args.add("-f \"" + FilenameUtils.separatorsToUnix(buildFile) + "\""); } if (target != null) { args.add(target); } return StringUtils.join(args, " "); }
private String getSrcFilePath(ZipEntry entry) { String parent = new File(srcFile).getParent(); return FilenameUtils.separatorsToUnix(new File(parent, entry.getName()).getPath()); }
protected String destURL(File rootPath, File file, String src, String dest) { String trimmedPattern = rtrimStandardrizedWildcardTokens(src); if (StringUtils.equals(FilenameUtils.separatorsToUnix(trimmedPattern), FilenameUtils.separatorsToUnix(src))) { return dest; } String trimmedPath = removeStart(subtractPath(rootPath, file), FilenameUtils.separatorsToUnix(trimmedPattern)); if (!StringUtils.startsWith(trimmedPath, "/") && StringUtils.isNotEmpty(trimmedPath)) { trimmedPath = "/" + trimmedPath; } return dest + trimmedPath; }
protected String destinationURL(File rootPath, File file, String src, String dest) { String trimmedPattern = rtrimStandardrizedWildcardTokens(src); if (StringUtils.equals(FilenameUtils.separatorsToUnix(trimmedPattern), FilenameUtils.separatorsToUnix(src))) { return dest; } String trimmedPath = removeStart(subtractPath(rootPath, file), FilenameUtils.separatorsToUnix(trimmedPattern)); if (!StringUtils.startsWith(trimmedPath, "/") && StringUtils.isNotEmpty(trimmedPath)) { trimmedPath = "/" + trimmedPath; } return dest + trimmedPath; }
public String getFullViewPath() { if (StringUtils.isBlank(assetRoot)) { return viewPath; } int positionOfQueryParamStart = viewPath.indexOf('?'); String viewPathWithoutQueryParams = positionOfQueryParamStart == -1 ? viewPath : viewPath.substring(0, positionOfQueryParamStart); String queryParams = positionOfQueryParamStart == -1 ? "" : viewPath.substring(positionOfQueryParamStart); return URI.create(FilenameUtils.separatorsToUnix(Paths.get(assetRoot, viewPathWithoutQueryParams).toString()) + queryParams).normalize().toString(); }
public static String join(File defaultWorkingDir, String actualFileToUse) { if (actualFileToUse == null) { LOGGER.trace("Using the default Directory->{}", defaultWorkingDir); return FilenameUtils.separatorsToUnix(defaultWorkingDir.getPath()); } return applyBaseDirIfRelativeAndNormalize(defaultWorkingDir, new File(actualFileToUse)); }
private Properties computeChecksumForContentsOfDirectory(File directory, String destPath) throws IOException { Collection<File> fileStructure = FileUtils.listFiles(directory, null, true); Properties checksumProperties = new Properties(); for (File file : fileStructure) { String filePath = removeStart(file.getAbsolutePath(), directory.getParentFile().getAbsolutePath()); try (FileInputStream inputStream = new FileInputStream(file)) { checksumProperties.setProperty(getEffectiveFileName(destPath, FilenameUtils.separatorsToUnix(filePath)), md5Hex(inputStream)); } } return checksumProperties; }
private Properties computeChecksumForContentsOfDirectory(File directory, String destPath) throws IOException { Collection<File> fileStructure = FileUtils.listFiles(directory, null, true); Properties checksumProperties = new Properties(); for (File file : fileStructure) { String filePath = removeStart(file.getAbsolutePath(), directory.getParentFile().getAbsolutePath()); try (FileInputStream inputStream = new FileInputStream(file)) { checksumProperties.setProperty(getEffectiveFileName(destPath, FilenameUtils.separatorsToUnix(filePath)), md5Hex(inputStream)); } } return checksumProperties; }
public File cachedFile(ArtifactFolder artifactFolder) { File root = artifactsDirHolder.getArtifactsDir(); String relativize = FilenameUtils.separatorsToUnix(artifactFolder.getRootFolder().getPath()).replaceFirst(FilenameUtils.separatorsToUnix(root.getPath()), CACHE_ARTIFACTS_FOLDER); return new File(root, removeTrailingSlash(relativize) + ".zip"); } }
/** * Converts all separators to the system separator. * * @param path the path to be changed, null ignored * @return the updated path */ public static String separatorsToSystem(final String path) { if (path == null) { return null; } if (isSystemWindows()) { return separatorsToWindows(path); } else { return separatorsToUnix(path); } }
/** * Checks and normalizes the given path. * * @param path The path to clean up * @return a normalized version of the path, with single separators between path components and * dot components resolved * @throws InvalidPathException if the path is invalid */ public static String cleanPath(String path) throws InvalidPathException { validatePath(path); return FilenameUtils.separatorsToUnix(FilenameUtils.normalizeNoEndSeparator(path)); }
@Test public void testSeparatorsToUnix() { assertEquals(null, FilenameUtils.separatorsToUnix(null)); assertEquals("/a/b/c", FilenameUtils.separatorsToUnix("/a/b/c")); assertEquals("/a/b/c.txt", FilenameUtils.separatorsToUnix("/a/b/c.txt")); assertEquals("/a/b/c", FilenameUtils.separatorsToUnix("/a/b\\c")); assertEquals("/a/b/c", FilenameUtils.separatorsToUnix("\\a\\b\\c")); assertEquals("D:/a/b/c", FilenameUtils.separatorsToUnix("D:\\a\\b\\c")); }