Counts Files, Folders, Lines of Code and other statistical Information.
@access		public
@param		string		$path			Folder to count within
@param		array		$extensions		List of Code File Extensions
@return		array
480434
public function readFolder( $path, $extensions = array() )
	{
		$files			= array();
		$numberCodes	= 0;
		$numberDocs		= 0;
		$numberFiles	= 0;
		$numberLength	= 0;
		$numberLines	= 0;
		$numberStrips	= 0;

		$path	= preg_replace( "@^(.+)/?$@", "\\1/", $path );

		$st		= new Alg_Time_Clock();
		$lister	= new FS_Folder_RecursiveLister( $path );
		$lister->setExtensions( $extensions );
		$list	= $lister->getList();
		foreach( $list as $entry )
		{
			$fileName	= str_replace( "\\", "/", $entry->getFilename() );
			$pathName	= str_replace( "\\", "/", $entry->getPathname() );
			
			if( substr( $fileName, 0, 1 ) == "_" )
				continue;
			if( preg_match( "@/_@", $pathName ) )
				continue;

			$countData	= FS_File_CodeLineCounter::countLines( $pathName );
			
			unset( $countData['linesCodes'] );
			unset( $countData['linesDocs'] );
			unset( $countData['linesStrips'] );

			$numberLength		+= $countData['length'];
			$numberLines		+= $countData['linesTotal'];
			
			$numberFiles		++;
			$numberStrips		+= $countData['numberStrips'];
			$numberCodes		+= $countData['numberCodes'];
			$numberDocs			+= $countData['numberDocs'];
			$files[$pathName]	= $countData;
		}
		$linesPerFile	= $numberLines / $numberFiles;
		$this->data	= array(
			'number'	=> array(
				'files'		=> $numberFiles,
				'lines'		=> $numberLines,
				'codes'		=> $numberCodes,
				'docs'		=> $numberDocs,
				'strips'	=> $numberStrips,
				'length'	=> $numberLength,
			),
			'ratio'			=> array(
				'linesPerFile'		=> round( $linesPerFile, 0 ),
				'codesPerFile'		=> round( $numberCodes / $numberFiles, 0 ),
				'docsPerFile'		=> round( $numberDocs / $numberFiles, 0 ),
				'stripsPerFile'		=> round( $numberStrips / $numberFiles, 0 ),
				'codesPerFile%'		=> round( $numberCodes / $numberFiles / $linesPerFile * 100, 1 ),
				'docsPerFile%'		=> round( $numberDocs / $numberFiles / $linesPerFile * 100, 1 ),
				'stripsPerFile%'	=> round( $numberStrips / $numberFiles / $linesPerFile * 100, 1 ),
			), 
			'files'		=> $files,
			'seconds'	=> $st->stop( 6 ),
			'path'		=> $path,
		);
	}
489926
private function getFiles($path)
    {
        $files = array();

        foreach (new \DirectoryIterator($path) as $file) {
            if ($file->isDot()
                || (null != $this->scriptName && sprintf('%s.php', $this->scriptName) != $file->getFilename())
            ) {
                continue;
            }

            $files[$file->getFilename()] = sprintf('%s/%s', $file->getPath(), $file->getFilename());
        }
        sort($files);

        return $files;
    }
1181787
def countfiles(path, recurse=False):
    """"""
    if not op.isdir(path):
        return 0
    count = 0
    for r,ds,fs in os.walk(path):
        count += len(fs)
        if not recurse:
            break
    return count
1178729
protected function findNewFiles(string $path) : array
    {
        $arrReturn = [];
        $arrFolders = scandir($path);
        $arrSkip = [
            '.',
            '..',
        ];
        
        foreach ($arrFolders as $file) {
            //No Folder Defaults
            if (in_array($file, $arrSkip)) {
                continue;
            }
            //Process Subfolders
            if (is_dir($path.$file)) {
                $arrSubFolderFiles = $this->findNewFiles($path.$file."/");
                $arrReturn = $this->addArrayToNewFiles($arrSubFolderFiles, $arrReturn);
                continue;
            }
            $arrReturn[] = $path.$file;
        }
        
        //Remove file from list if already processed
        foreach($arrReturn as $key => $file) {
            if (in_array($file, $this->knownUpdateFiles)) {
                unset($arrReturn[$key]);
            }
        }
        return $arrReturn;
    }
54984
protected function filterPath($path, $pattern, array $extensions=[])
    {
        $usePattern = $this->isFilterPattern($pattern);

        if (!$usePattern && !$extensions) {
            return true;
        }

        if ($usePattern && !fnmatch($pattern, $this->basename($path))) {
            return false;
        }

        if ($extensions && !in_array(strtolower($this->extension($path)), $extensions)) {
            return false;
        }

        return true;
    }
969401
public function uploadAll($files,$path){
        if( is_array($files) && count($files) > 0 ){
            $n = count($files);
            if( $n <= $this->config['upload']['number'] ){
                $res = array();
                $notresult = array();
                foreach ($files as $key => $value) {
                    $file = $this->upload($value,$path);
                    if( $file ){
                        $this->createThumb($file,$path);
                        $res[] = $file->getFilename();
                    }else{
                        $notresult[] = $value->getClientOriginalName();
                    }
                }
                $r = '';
                $n2 = count($res);
                $result = array("query"=>"BE_UPLOADALL_UPLOADS %s / %s","params"=>array($n2,$n));
                if(count($notresult)>0){
                    $result['query'] = $result['query'].' | BE_UPLOADALL_NOT_UPLOADS ';
                    $i=0;
                    $n = count($notresult);
                    foreach ($notresult as $value) {
                        $result['query'] = $result['query'] . ' %s';
                        if( $n - 1 > $i ){
                            $result['query'] = $result['query'] . ',';
                            $value = $value.',';
                        }
                        $result['params'][] = $value;
                        $i++;

                    }
                    $this->setInfo(array("status"=>0));
                }
                $this->setInfo(array("msg"=>$result));
                return $res;
            }else{
                $result = array("query"=>"BE_UPLOAD_MAX_UPLOAD %s","params"=>array($this->config['upload']['number']));
                $this->setInfo(array("msg"=>$result,"status"=>0));
            }
        }else{
            return ;
        }
    }
647592
public static function GetDirContent($path)
    {
        $files = array();
        $directory = opendir($path);

        while(($file = readdir($directory)) !== false)
        {
            $full_path = $path . "/" . $file;

            if(is_file($full_path))
            {
                $files[] = $full_path;
            }
            elseif($file != "." && $file != ".." && is_dir($full_path))
            {
                $files[] = $full_path;
                $files = array_merge($files, self::GetDirContent($full_path));
            }
        }

        closedir($directory);

        return $files;
    }
740791
protected function getExtension($path)
    {
        $extensions = array_keys($this->extensions);

        return array_first($extensions, function($key, $value) use ($path)
        {
            return ends_with($path, $value);
        });
    }
91131
public static function findDirs(string $path): array
    {
        $result = [];

        try {
            static::validatePath($path);
            $path = new DirectoryIterator($path);
        } catch (InvalidArgumentException $e) {
            return $result;
        } catch (UnexpectedValueException $e) {
            return $result;
        }

        foreach ($path as $dir) {
            if ($dir->isDot()) {
                continue;
            }
            if (!$dir->isDir()) {
                continue;
            }
            $result[] = $dir->getFilename();
        }
        asort($result);

        return $result;
    }
478872
public function parsePhpFiles($path)
    {
        $files = $this->finderFactory->createFinder()->in($path);
        $parsedFiles = array();
        $parserErrors = array();

        $this->progressOutput->start($fileCount = $files->count());

        $i = 0;
        foreach ($files->getIterator() as $file) {
            $file = PhpFileInfo::create($file);

            try {
                $this->progressOutput->advance(++$i, $file);
                $this->parser->parseFile($file);
            } catch (Error $ex) {
                $raw = $ex->getRawMessage().' in file '.$file;
                $ex->setRawMessage($raw);
                $parserErrors[] = $ex;
            }

            $parsedFiles[] = $file;
        }

        $this->progressOutput->end();

        return new Result($parsedFiles, $parserErrors, $fileCount);
    }
1294337
public function scan( $path )
	{
		$this->numberFound		= 0;
		$this->numberScanned	= 0;
		$this->numberTodos		= 0;
		$this->numberLines		= 0;
		$this->list				= array();
		$extensions		= $this->getExtensionPattern(); 
		$pattern		= $this->getExtendedPattern();
		$iterator		= $this->getIndexIterator( $path, $extensions );
		try{
			foreach( $iterator as $entry )
			{
				$this->numberScanned++;
				$content	= file_get_contents( $entry->getPathname() );
				$lines		= explode( "\n", $content );
				$i			= 0;
				$list		= array();
				foreach( $lines as $line )
				{
					$this->numberLines++;
					$i++;
					if( !preg_match( $pattern, $line ) )
						continue;
					$this->numberTodos++;
					$list[$i]	= $line;#trim( $line );
				}
				if( !$list )
					continue;
				$this->numberFound++;
				$this->list[$entry->getPathname()]	= array(
					'fileName'	=> $entry->getFilename(),
					'lines'		=> $list,
				);
			}
		}
		catch( UnexpectedValueException $e ){
		}
		catch( Exception $e ){
			throw new RuntimeException( $e->getMessage(), $e->getCode(), $es );
		}
	}
243609
public function isLast($path)
    {
        return $this->items && $path === array_keys($this->items)[\count($this->items) - 1];
    }
863962
protected function getCountForFiles(array $files)
    {
        $analyserClass = '\\SebastianBergmann\\PHPLOC\\Analyser';
        $analyser = new $analyserClass();

        return $analyser->countFiles($files, $this->countTests);
    }
1141252
public function files($directory, $pattern = '*', $extensions = '')
    {
        $files = $this->formatDirsAndFiles($this->laravelFS->files($directory));

        $extensions = $extensions ? (array)$extensions : [];

        return $this->filterPaths($files, $pattern, $extensions);
    }
1150169
public function getFileListByExtensions( $extensions )
	{
		$lister	= new FS_Folder_Lister( $this->folderName );
		$lister->setExtensions( $extensions );
		$lister->showFolders( FALSE );
		return $lister->getList();
	}
722382
public function getFilesInDir($dir_path, array $file_extensions)
    {
        $file_paths = [];

        /** @var \RecursiveDirectoryIterator */
        $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir_path));
        $iterator->rewind();

        while ($iterator->valid()) {
            if (!$iterator->isDot()) {
                $extension = $iterator->getExtension();
                if (in_array($extension, $file_extensions, true)) {
                    $file_paths[] = (string)$iterator->getRealPath();
                }
            }

            $iterator->next();
        }

        return $file_paths;
    }
267089
def _count_files_by_type(self, path, pattern, ignore=True):
        
        # Get all files matching the given path and pattern
        files = glob(os.path.join(path, pattern))
        # Count the files
        files = [ff for ff in files
                 if os.path.split(ff)[-1] not in self._IGNORE_FILES
                 or not ignore]
        num_files = len(files)
        return num_files