Gary Feldman wrote:
I'm trying to create a fileset that goes one level deep, to pick out subdirectories. In other words, I have a tree that looks like:

   root/
       project1/
           testresults/
       project2/
           testresults/

I've tried both
   <include basedir="root" name="*/testresults/*.result.xml" />
and
   <include basedir="root" name="/*/testresults/*.result.xml" />

Both of these wind up walking the entire tree, instead of just going the through the top level. So it takes several minutes (as compared to the cygwin bash command:

The fileset directory scanning logic in NAnt is somewhat unintelligent as to how deep it goes. We made this tradeoff in the past so that we can better combine multiple recursive filesets without a major performance hit. For instance, NAnt's filescanner is just as fast to scan "**/*.xml" as it is to scan both "**/*.xml" and "**/*.java". Cygwin's globbing has a much easier task - it only needs to evaluate each path segment wildcard once. :)

Internally, we have a flag "isRecursive" that we set on patterns that reflects whether the pattern potentially matches more than a single directory:

// The pattern is potentially recursive if and only if more than one base directory could be matched.
    // ie:
    //    **
    //    **/*.txt
    //    foo*/xxx
    //    x/y/z?/www
    // This condition is true if and only if:
    //  - The first wildcard is before the last directory separator, or
    //  - The pattern contains a directory wildcard ("**")
recursive = (indexOfFirstWildcard != -1 && (indexOfFirstWildcard < indexOfLastOriginalDirectorySeparator )) || indexOfFirstDirectoryWildcard != -1;

We could probably fix this by changing "isRecursive" to "maxRecursiveLevel", but this would be a major change that would require a lot of testing.

The ideal design would be to calculate and store the maximum recursive depth for each given base directory, aggregating common base directories to a single scanning root. Note that a base directory is the base path of a pattern that can match one and only one directory. We can then scan the set of base directories down to the maximum recursive level (infinite in the case of a "**" pattern) specified for that given base directory.

Matt.


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Nant-users mailing list
Nant-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to