in clearcase-common/src/jetbrains/buildServer/vcs/clearcase/Util.java [459:519]
private DirectoryInfo expand(int baseDirectoryPathLength, File currentDirectory, Pattern pattern, boolean recursive) {
LOGGER.info("\n\tcurrent directory: \"" + currentDirectory + "\"\n\tpattern: \"" + pattern + "\"");
// feed the listeners
propertyChangeSupport.firePropertyChange(FILE_PROPERTY, null, currentDirectory);
if (!currentDirectory.exists()) {
LOGGER.warn(currentDirectory + " does not exist");
return null;
}
if (!currentDirectory.isDirectory()) {
LOGGER.warn(currentDirectory + " is no directory");
return null;
}
if (!currentDirectory.canRead()) {
LOGGER.warn("can not read " + currentDirectory);
return null;
}
if (pattern == null) {
throw new IllegalArgumentException("pattern must not be null");
}
LOGGER.debug("recursing directory " + currentDirectory);
long tmpByteCount = 0;
List<File> files = new ArrayList<File>();
for (File subFile : currentDirectory.listFiles()) {
// check if subfile matches
String relativePath = subFile.getPath().substring(baseDirectoryPathLength);
if (pattern.matcher(relativePath).matches()) {
LOGGER.debug(subFile + " matches");
if (subFile.isDirectory()) {
// copy directories itself only when using recursive mode
if (recursive) {
files.add(subFile);
}
} else {
files.add(subFile);
tmpByteCount += subFile.length();
}
} else {
LOGGER.debug(subFile + " does not match");
}
// recurse directories
if (subFile.isDirectory()) {
if (recursive) {
DirectoryInfo tmpInfo = expand(baseDirectoryPathLength, subFile, pattern, recursive);
if (tmpInfo != null) {
files.addAll(tmpInfo.getFiles());
tmpByteCount += tmpInfo.getByteCount();
}
}
}
}
return new DirectoryInfo(currentDirectory, files, tmpByteCount);
}