private List<File> getFilesForPattern(File baseDir, String pathPattern, boolean libraryProperty) { String dirPath = pathPattern; String filePattern; int wildcardIndex = pathPattern.indexOf('*'); if (wildcardIndex >= 0) { dirPath = pathPattern.substring(0, wildcardIndex); } int lastPathSeparator = Math.max(dirPath.lastIndexOf('/'), dirPath.lastIndexOf('\\')); if (lastPathSeparator == -1) { dirPath = "."; filePattern = pathPattern; } else { dirPath = pathPattern.substring(0, lastPathSeparator); filePattern = pathPattern.substring(lastPathSeparator + 1); } File dir = resolvePath(baseDir, dirPath); if (!dir.isDirectory()) { return Lists.newArrayList(); } return getMatchingFiles(filePattern, dir, libraryProperty); }
private List<File> getFilesForPattern(File baseDir, String pathPattern, boolean libraryProperty) { String dirPath = pathPattern; String filePattern; int wildcardIndex = pathPattern.indexOf('*'); if (wildcardIndex >= 0) { dirPath = pathPattern.substring(0, wildcardIndex); } int lastPathSeparator = Math.max(dirPath.lastIndexOf('/'), dirPath.lastIndexOf('\\')); if (lastPathSeparator == -1) { dirPath = "."; filePattern = pathPattern; } else { dirPath = pathPattern.substring(0, lastPathSeparator); filePattern = pathPattern.substring(lastPathSeparator + 1); } File dir = resolvePath(baseDir, dirPath); if (!dir.isDirectory()) { return Lists.newArrayList(); } return getMatchingFiles(filePattern, dir, libraryProperty); }
private Set<File> getFilesForPattern(Path baseDir, String pathPattern, boolean libraryProperty) { try { Path filePath = resolvePath(baseDir, pathPattern); File file = filePath.toFile(); if(file.isFile()) { return getMatchingFile(pathPattern, file); } if (file.isDirectory()) { return getMatchesInDir(filePath, libraryProperty); } } catch (IOException | InvalidPathException e) { // continue } String dirPath = sanitizeWildcards(pathPattern); String fileNamePattern = pathPattern; int lastPathSeparator = Math.max(dirPath.lastIndexOf(UNIX_SEPARATOR), dirPath.lastIndexOf(WINDOWS_SEPARATOR)); if (lastPathSeparator == -1) { dirPath = "."; } else { dirPath = pathPattern.substring(0, lastPathSeparator); fileNamePattern = pathPattern.substring(lastPathSeparator + 1); } Path dir = resolvePath(baseDir, dirPath); return getFilesInDir(dir, fileNamePattern, libraryProperty); }
private Set<File> getFilesForPattern(Path baseDir, String pathPattern, boolean libraryProperty) { try { Path filePath = resolvePath(baseDir, pathPattern); File file = filePath.toFile(); if(file.isFile()) { return getMatchingFile(pathPattern, file); } if (file.isDirectory()) { return getMatchesInDir(filePath, libraryProperty); } } catch (IOException | InvalidPathException e) { // continue } String dirPath = sanitizeWildcards(pathPattern); String fileNamePattern = pathPattern; int lastPathSeparator = Math.max(dirPath.lastIndexOf(UNIX_SEPARATOR), dirPath.lastIndexOf(WINDOWS_SEPARATOR)); if (lastPathSeparator == -1) { dirPath = "."; } else { dirPath = pathPattern.substring(0, lastPathSeparator); fileNamePattern = pathPattern.substring(lastPathSeparator + 1); } Path dir = resolvePath(baseDir, dirPath); return getFilesInDir(dir, fileNamePattern, libraryProperty); }