Returns Number of Files and Folders within current Folder.
@access		public
@param		string		$pattern		RegEx Pattern for Name Filter
@return		int
339877
public function getCount( $pattern = NULL )
	{
		$count	= 0;
		$list	= $this->getList( $pattern );
		foreach( $list as $entry )
			$count++;
		return $count;
	}
723784
public function find(string $pattern, int $flags = 0): Collection
    {
        $files = glob($this->path.'/'.$pattern, $flags);
        foreach ($files as $index => $file) {
            if (is_dir($file)) {
                $files[$index] = new self($file);
            } else {
                $files[$index] = new File($file);
            }
        }

        return new Collection($files);
    }
1031267
public static function getNameCount(String $get) : Int
    {
        $segArr = self::segmentArray();

        if( in_array($get, $segArr) )
        {
            $segVal = array_search($get, $segArr);

            return count($segArr) - 1 - $segVal;
        }

        return false;
    }
560117
public function getFolders($regex = null, $recursive = false)
    {
        //argument test
        Argument::i()
            //argument 1 must be a string
            ->test(1, 'string', 'null')
            //argument 2 must be a boolean
            ->test(2, 'bool');

        $this->absolute();

        $folders = array();

        if ($handle = opendir($this->data)) {
            //walk the directory
            while (false !== ($folder = readdir($handle))) {
                // If this is infact a directory
                //and if it matches the regex
                if ($folder != '.' && $folder != '..'
                      && filetype($this->data .'/'. $folder) == 'dir'
                    && (!$regex || preg_match($regex, $folder))) {
                    //add it
                    $folders[] = self::i($this->data . '/' . $folder);
                    if ($recursive) {
                        $subfolders = self::i($this->data.'/'.$folder);
                        $folders = array_merge($folders, $subfolders->getFolders($regex, $recursive));
                    }

                }
            }
            closedir($handle);
        }

        return $folders;
    }
123054
public function directoryLength($directory = '')
    {
        if ($items = glob($this->rootDir .'/'. trim($directory, '/') .'/*')) {
            return count($items);
        }

        return 0;
    }
624482
private function matchPattern($pattern) {
        $regex = $this->patternToRegex($pattern);
        $result = preg_match($regex, $this->pathInfo);
        if ($result === false) {
            throw new Exception("拦截器匹配发生错误，错误的pathinfo模式：{$pattern}");
        }

        return $result == 1;
    }
349365
public static function createPattern($pattern)
    {
        $numVer = '([0-9]+|x|\*)';
        $numVer2 = '('.$numVer.'\.'.$numVer.')';
        $numVer3 = '('.$numVer.'\.'.$numVer.'\.'.$numVer.')';

        return '/^'.'('.$numVer.'|'.$numVer2.'|'.$numVer3.')'.$pattern.'/';
    }
1242904
public function globr($dir, $pattern, $flags = NULL)
    {
        $files = $this->glob("$dir/$pattern", $flags);
        if ($files === false) $files = array();
        $sub_dirs = $this->glob("$dir/*", GLOB_ONLYDIR);
        if ($sub_dirs === false) $sub_dirs = array();
        foreach ($sub_dirs as $sub_dir) {
            $sub_files = $this->globr($sub_dir, $pattern, $flags);
            $files = array_merge($files, $sub_files);
        }
        return $files;
    }
747265
public function grep($pattern)
    {
        $results = array_intersect_key($this->attributes, array_flip(
            RegexGuard::getGuard()->grep($pattern, array_keys($this->attributes))
        ));

        return new static($results);
    }
1244759
public static function getDirSizeCount($dir)
    {
        if (!is_dir($dir)) {
            throw new RuntimeException(sprintf('Invalid directory path supplied "%s"', $dir));
        }

        $count = 0.00;
        $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));

        foreach ($iterator as $file) {
            $count += $file->getSize(); 
        }

        return $count;
    }
1235228
protected static function getAllBlades($pattern = null, $traversePostOrder = 0)
    {
        if (!$pattern) {
            $pattern = get_template_directory() . '/app/views/**/*.blade.php';
        }

        $patternParts = explode('/**/', $pattern);
        $dirs = glob(array_shift($patternParts) . '/*', GLOB_ONLYDIR | GLOB_NOSORT);
        $files = glob(str_replace('/**/', '/', $pattern));
        foreach ($dirs as $dir) {
            $subDirContent = self::getAllBlades($dir . '/**/' . implode('/**/', $patternParts), $traversePostOrder);
            if (!$traversePostOrder) {
                $files = array_merge($files, $subDirContent);
            } else {
                $files = array_merge($subDirContent, $files);
            }
        }
        return $files;
    }
1174478
public function hasFilesWithName($pattern)
    {
        $result = $this->getFiles(Finder::create()->name($pattern));

        return count($result) !== 0;
    }
1271776
public function readDirRecursive( $dir, $pattern ) {

		$sub_dirs = glob( $dir . '/*', \GLOB_ONLYDIR );
		$files = array();
		if ( ! empty( $sub_dirs ) ) {
			foreach ( $sub_dirs as $sub_dir ) {
				$files = array_merge( $files, $this->readDirRecursive( $sub_dir, $pattern ) );
			}
		}
		$files = array_merge( $files, glob( $dir . '/' . $pattern, \GLOB_NOCHECK ) );

		return $files;
	}
804496
public function getFileCount( $pattern = NULL )
	{
		$count	= 0;
		foreach( $this->getFileList( $pattern ) as $entry )
			$count++;
		return $count;
	}
500021
protected function splitRoutePattern($pattern)
    {
        if (strpos($pattern, ' ') !== false && preg_match_all('/\s+\+(\w+)\b|\s+\-(\w+)\b/', $pattern, $matches)) {
            list($path) = preg_split('/\s+/', $pattern, 2);
            $inc = isset($matches[1]) ? array_filter($matches[1]) : [];
            $excl = isset($matches[2]) ? array_filter($matches[2]) : [];
        } else {
            $path = $pattern;
            $inc = [];
            $excl = [];
        }
        
        return [$path, $inc, $excl];
    }
80881
private function globRecursive($pattern)
    {
        $paths = glob($pattern);
        foreach ($paths as $path) {
            if (strpos($path, '.') === false) {
                $paths = array_merge($paths, $this->globRecursive($path . '/*'));
            }
        }
        return $paths;
    }
279140
public function getNestedCount( $pattern = NULL )
	{
		$count	= 0;
		foreach( $this->getNestedList( $pattern ) as $entry )
			$count++;
		return $count;
	}