src/Charcoal/App/Script/PathScriptTrait.php
public function globRecursive($pattern, $flags = 0)
    {
        $maxDepth = $this->maxDepth();
        $depthKey = strval($maxDepth);

        if (isset(static::$globCache[$pattern][$depthKey])) {
            return static::$globCache[$pattern][$depthKey];
        }

        $depth = 1;
        $files = glob($pattern, $flags);
        foreach (glob(dirname($pattern).'/*', (GLOB_ONLYDIR|GLOB_NOSORT)) as $dir) {
            $files = array_merge($files, $this->globRecursive($dir.'/'.basename($pattern), $flags));
            $depth++;
            if ($maxDepth > 0 && $depth >= $maxDepth) {
                break;
            }
        }

        static::$globCache[$pattern][$depthKey] = array_filter($files, 'is_file');

        return $files;
    }
public function globRecursive($pattern, $flags = 0)
    {
        $maxDepth = $this->maxDepth();
        $depthKey = strval($maxDepth);

        if (isset(static::$globCache[$pattern][$depthKey])) {
            return static::$globCache[$pattern][$depthKey];
        }

        $depth = 1;
        $files = glob($pattern, $flags);
        foreach (glob(dirname($pattern).'/*', (GLOB_ONLYDIR|GLOB_NOSORT)) as $dir) {
            $files = array_merge($files, $this->globRecursive($dir.'/'.basename($pattern), $flags));
            $depth++;
            if ($maxDepth > 0 && $depth >= $maxDepth) {
                break;
            }
        }

        static::$globCache[$pattern][$depthKey] = array_filter($files, 'is_file');

        return $files;
    }
public function globRecursive ( $ pattern , $ flags = 0 ) { $ maxDepth = $ this -> maxDepth ( ) ; $ depthKey = strval ( $ maxDepth ) ; if ( isset ( static :: $ globCache [ $ pattern ] [ $ depthKey ] ) ) { return static :: $ globCache [ $ pattern ] [ $ depthKey ] ; } $ depth = 1 ; $ files = glob ( $ pattern , $ flags ) ; foreach ( glob ( dirname ( $ pattern ) . '/*' , ( GLOB_ONLYDIR | GLOB_NOSORT ) ) as $ dir ) { $ files = array_merge ( $ files , $ this -> globRecursive ( $ dir . '/' . basename ( $ pattern ) , $ flags ) ) ; $ depth ++ ; if ( $ maxDepth > 0 && $ depth >= $ maxDepth ) { break ; } } static :: $ globCache [ $ pattern ] [ $ depthKey ] = array_filter ( $ files , 'is_file' ) ; return $ files ; }
Recursively find pathnames matching a pattern.

@see    http://in.php.net/manual/en/function.glob.php#106595
@param  string  $pattern The search pattern.
@param  integer $flags   Bitmask of {@see glob()} options.
@return array
Recursively find pathnames matching a pattern .