classes/Builder.php
static function pake_antpattern( $files, $rootdir )
    {
        $results = array();
        foreach( $files as $file )
        {
            //echo " Beginning with $file in dir $rootdir\n";

            // safety measure: try to avoid multiple scans
            $file = str_replace( '/**/**/', '/**/', $file );

            $type = 'any';
            // if user set '/ 'as last char: we look for directories only
            if ( substr( $file, -1 ) == '/' )
            {
                $type = 'dir';
                $file = substr( $file, 0, -1 );
            }
            // managing 'any subdir or file' as last item: trick!
            if ( strlen( $file ) >= 3 && substr( $file, -3 ) == '/**' )
            {
                $file .= '/*';
            }

            $dir = dirname( $file );
            $file = basename( $file );
            if ( strpos( $dir, '**' ) !== false )
            {
                $split = explode( '/', $dir );
                $path = '';
                foreach( $split as $i => $part )
                {
                    if ( $part != '**' )
                    {
                        $path .= "/$part";
                    }
                    else
                    {
                        //echo "  Looking for subdirs in dir $rootdir{$path}\n";
                        $newfile = implode( '/', array_slice( $split, $i + 1 ) ) . "/$file" . ( $type == 'dir'? '/' : '' );
                        $dirs = pakeFinder::type( 'dir' )->in( $rootdir . $path );
                        // also cater for the case '** matches 0 subdirs'
                        $dirs[] = $rootdir . $path;
                        foreach( $dirs as $newdir )
                        {
                            //echo "  Iterating in $newdir, looking for $newfile\n";
                            $found = self::pake_antpattern( array( $newfile ), $newdir );
                            $results = array_merge( $results, $found );
                        }
                        break;
                    }
                }
            }
            else
            {
                //echo "  Looking for $type $file in dir $rootdir/$dir\n";
                $found = pakeFinder::type( $type )->name( $file )->maxdepth( 0 )->in( $rootdir . '/' . $dir );
                //echo "  Found: " . count( $found ) . "\n";
                $results = array_merge( $results, $found );
            }
        }
        return $results;
    }
static function pake_antpattern( $files, $rootdir )
    {
        $results = array();
        foreach( $files as $file )
        {
            //echo " Beginning with $file in dir $rootdir\n";

            // safety measure: try to avoid multiple scans
            $file = str_replace( '/**/**/', '/**/', $file );

            $type = 'any';
            // if user set '/ 'as last char: we look for directories only
            if ( substr( $file, -1 ) == '/' )
            {
                $type = 'dir';
                $file = substr( $file, 0, -1 );
            }
            // managing 'any subdir or file' as last item: trick!
            if ( strlen( $file ) >= 3 && substr( $file, -3 ) == '/**' )
            {
                $file .= '/*';
            }

            $dir = dirname( $file );
            $file = basename( $file );
            if ( strpos( $dir, '**' ) !== false )
            {
                $split = explode( '/', $dir );
                $path = '';
                foreach( $split as $i => $part )
                {
                    if ( $part != '**' )
                    {
                        $path .= "/$part";
                    }
                    else
                    {
                        //echo "  Looking for subdirs in dir $rootdir{$path}\n";
                        $newfile = implode( '/', array_slice( $split, $i + 1 ) ) . "/$file" . ( $type == 'dir'? '/' : '' );
                        $dirs = pakeFinder::type( 'dir' )->in( $rootdir . $path );
                        // also cater for the case '** matches 0 subdirs'
                        $dirs[] = $rootdir . $path;
                        foreach( $dirs as $newdir )
                        {
                            //echo "  Iterating in $newdir, looking for $newfile\n";
                            $found = self::pake_antpattern( array( $newfile ), $newdir );
                            $results = array_merge( $results, $found );
                        }
                        break;
                    }
                }
            }
            else
            {
                //echo "  Looking for $type $file in dir $rootdir/$dir\n";
                $found = pakeFinder::type( $type )->name( $file )->maxdepth( 0 )->in( $rootdir . '/' . $dir );
                //echo "  Found: " . count( $found ) . "\n";
                $results = array_merge( $results, $found );
            }
        }
        return $results;
    }
Mimics ant pattern matching.

@see http://ant.apache.org/manual/dirtasks.html#patterns
@todo in pake 1.6.3 and later this functionality is supported natively. To be removed
@todo more complete testing
@bug looking for " d i r / * * / " will return subdirs but not dir itself