in nuget-agent/src/jetbrains/buildServer/nuget/agent/util/fsScanner/DirectoryScanner.java [106:155]
private static void findFilesRec(@NotNull final DirectoryEntry directory,
@NotNull final List<FileSystemPath> result,
@NotNull final List<AntPatternState> includeState,
@NotNull final List<AntPatternState> excludeState) {
LOG.debug("Scanning directory: " + directory.getName());
boolean mayContainFiles = false;
Collection<String> explicits = new HashSet<String>();
for (AntPatternState state : includeState) {
final Collection<String> nextTokens = state.nextTokes();
if (nextTokens == null) {
explicits = null;
mayContainFiles = true;
break;
}
if (!mayContainFiles) {
mayContainFiles = state.hasLastState();
}
explicits.addAll(nextTokens);
}
if (mayContainFiles) {
for (FileEntry file : explicits != null ? directory.getFiles(explicits) : directory.getFiles()) {
List<AntPatternState> newState = new ArrayList<AntPatternState>();
if (!any(includeState, file.getName(), equal(MatchResult.YES), newState))
continue;
if (any(excludeState, file.getName(), equal(MatchResult.YES), newState))
continue;
result.add(file.getPath());
}
}
for (DirectoryEntry subEntry : explicits != null ? directory.getSubdirectories(explicits) : directory.getSubdirectories()) {
String name = subEntry.getName();
List<AntPatternState> newIncludeState = new ArrayList<AntPatternState>();
if (!any(includeState, name, notEqual(MatchResult.NO), newIncludeState))
continue;
List<AntPatternState> newExcludeState = new ArrayList<AntPatternState>();
if (any(excludeState, name, equal(MatchResult.YES), newExcludeState))
continue;
findFilesRec(subEntry, result, newIncludeState, newExcludeState);
}
}