private void doVisitDirOrFile(FileVisitor visitor, File file, LinkedList<String> relativePath, int segmentIndex, AtomicBoolean stopFlag) {
if (file.isFile()) {
if (segmentIndex == patternSegments.size()) {
RelativePath path = new RelativePath(true, relativePath.toArray(new String[relativePath.size()]));
FileVisitDetails details = new DefaultFileVisitDetails(file, path, stopFlag, fileSystem, fileSystem);
if (!excludeSpec.isSatisfiedBy(details)) {
visitor.visitFile(details);
}
}
} else if (file.isDirectory()) {
RelativePath path = new RelativePath(false, relativePath.toArray(new String[relativePath.size()]));
FileVisitDetails details = new DefaultFileVisitDetails(file, path, stopFlag, fileSystem, fileSystem);
if (!excludeSpec.isSatisfiedBy(details)) {
visitor.visitDir(details);
}
if (segmentIndex < patternSegments.size()) {
doVisit(visitor, file, relativePath, segmentIndex, stopFlag);