You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by David Medinets <me...@mtolive.com> on 2000/09/13 23:30:45 UTC
DirectoryScanner & Excluding Directories
I hope the following is understandable.
In the scandir method of DirectoryScanner, the code looks like this for
directories:
if (isIncluded(name)) {
if (!isExcluded(name)) {
dirsIncluded.addElement(name);
if (fast) {
scandir(file, name+File.separator, fast);
}
} else {
dirsExcluded.addElement(name);
}
} else {
dirsNotIncluded.addElement(name);
if (fast && couldHoldIncluded(name)) {
scandir(file, name+File.separator, fast);
}
}
However, I'd like to use the following xml in my build.xml file:
<AnalyzeRequest debug="yes" srcdir="${src}">
<include name="*.cfm"/>
<exclude name="images"/>
</AnalyzeRequest>
I feel the above exclude should work, but it doesn't because if IsExcluded
test only occurs inside the IsIncluded test.
My solution was to wrap the whole above if statement with:
if (isExcluded(name)) {
dirsExcluded.addElement(name);
}
else {
... the original if statement
... move the scandir call here so that
... we don't recurse through excluded directories.
}
Comments? Is this a change that should find its way into the main code
base?
Re: DirectoryScanner & Excluding Directories
Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "DM" == David Medinets <me...@mtolive.com> writes:
DM> I feel the above exclude should work, but it doesn't because if
DM> IsExcluded test only occurs inside the IsIncluded test.
It depends on what you mean by "exclude should work". The
file/directory named images should not be listed in one of the
getIncluded... methods.
DirectoryScanner assigns three states to files or directories:
(1) included - what you'd expect. This file/dir has matched an include
pattern.
(2) excluded - This file/dir matches both an include and an exclude
pattern, exclude wins.
(3) not included - This file/dir doesn't match an include pattern.
So the opposite of getIncludedFiles() is the union of
getExcludedFiles() and getNotIncludedFiles().
I think we could savely change the semantics if they seem
counterintuitive as no tasks I'm aware of call anything but the
getIncluded... methods - or maybe we just need better documentation?
Stefan