Return files list in directory

@param  string  $path  dir path
@return array
@author Dmitry (dio) Levashov,
@author Alexey Sukhotin
515578
protected function _scandir($path) {
		
		$s3path = preg_replace("/^\//", "", $path) . '/';
		
		$files = $this->s3->ListBucket(array('Bucket' => $this->options['bucket'], 'delimiter' => '/', 'Prefix' => $s3path))->ListBucketResponse->Contents;
	
		$finalfiles = array();
		
		foreach ($files as $file) {
			if (preg_match("|^" . $s3path . "[^/]*/?$|", $file->Key)) {
				$fname = preg_replace("/\/$/", "", $file->Key);
				$fname = $file->Key;
				
				if ($fname != preg_replace("/\/$/", "", $s3path)) {
					
				}
				
				$finalfiles[] = $fname;
			}
		}
		
		sort($finalfiles);
		return $finalfiles;
	}
1211385
public function allFilesList($dir_path)
    {
        $files = [];
        if (File::exists($dir_path)) {
            $dir_files = File::allFiles($dir_path);
            foreach ($dir_files as $file) {
                $path = basename($file);
                $name = strstr(basename($file), '.', true);
                $files[$name] = $path;
            }
        }

        return $files;
    }
1187341
protected function _scandir($path) {
		$files = array();

 		foreach (ftp_rawlist($this->connect, $path) as $str) {
 			if (($stat = $this->parseRaw($str))) {
 				$files[] = $path.DIRECTORY_SEPARATOR.$stat['name'];
 			}
 		}

 		return $files;
	}
1132142
protected function loadFile($path) {
        $path = realpath($path);

        if ($this->matchEnvironment($path)) {
            foreach ($this->getDrivers() as $driver) {
                if ($driver->supports($path)) {
                    return $driver->loadFile($path);
                }
            }
        }

        return [];
    }
317963
public static function getFolder(string $path)
    {
        $arrFolders = explode(DIRECTORY_SEPARATOR, $path);
        $fullPath = "";
        if ($arrFolders[0] !== "") {
            $fullPath = $arrFolders[0];
        }
        unset($arrFolders[0]);
        foreach ($arrFolders as $folder) {
            $fullPath .= DIRECTORY_SEPARATOR . $folder;
            if (file_exists($fullPath) && is_dir($fullPath)) {
                continue;
            }
            mkdir($fullPath, 0775);
        }
        return $path;
    }
461918
protected function loadPath($path) {
        if (directory_exists($path)) {
            return $this->loadDirectory($path);
        } else if (file_exists($path)) {
            return $this->loadFile($path);
        }

        return [];
    }
1122543
protected function getConfigurationFiles($path)
	{
		$files = [];

		foreach (Finder::create()->files()->name('*.php')->in($path) as $file)
		{
			$files[basename($file->getRealPath(), '.php')] = $file->getRealPath();
		}

		return $files;
	}
933798
private function getFilePathCollection($path)
    {
        $key = \array_flip($this->filePathMapping)[$path];

        return $this->filePathCollection[$key];
    }
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;
    }
710179
protected function _scandir($path) {
		$files = array();
		
		foreach (scandir($path) as $name) {
			if ($name != '.' && $name != '..') {
				$files[] = $path.DIRECTORY_SEPARATOR.$name;
			}
		}
		return $files;
	}
547885
protected static function listProjectFiles( $path )
	{
		$list	= array();
		$dir	= new DirectoryIterator( $path );
		foreach( $dir as $entry )
		{
			if( $entry->isDot() )
				continue;
			if( !preg_match( "@\.gan$@", $entry->getFilename() ) )
				continue;
			$list[]	= $entry->getPathname();
		}
		return $list;
	}
850920
public function files(String $path, String $extension = NULL) : Array
    {
        $list = ftp_nlist($this->connect, $path);

        if( ! empty($list) ) foreach( $list as $file )
        {
            if( $file !== '.' && $file !== '..' )
            {
                if( ! empty($extension) && $extension !== 'dir' )
                {
                    if( Filesystem::getExtension($file) === $extension )
                    {
                        $files[] = $file;
                    }
                }
                else
                {
                    if( $extension === 'dir' )
                    {
                        $extens = Filesystem::getExtension($file);

                        if( empty($extens) )
                        {
                            $files[] = $file;
                        }
                    }
                    else
                    {
                        $files[] = $file;
                    }
                }
            }
        }

        if( ! empty($files) )
        {
            return $files;
        }
        else
        {
            return [];
        }
    }
378908
protected static function getFilesFromPath($path)
    {
        $files = [];
        $path = rtrim($path, '/') . DIRECTORY_SEPARATOR;

        if (false !== $items = scandir($path)) {
            foreach ($items as $item) {
                $file = $path . $item;
                if (is_file($file)) {
                    $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
                    if (in_array($extension, [Packager::FILE_EXTENSION, Package::FILE_EXTENSION])) {
                        $files[] = $file;
                    }
                }
            }
        }

        return $files;
    }
740244
private function getFiles($path)
    {
        if (is_file($path)) {
            return [new SplFileInfo($path, '', '')];
        }

        return $this->finder->name('*.php')->in(realpath($path));
    }
244268
private function getFiles($path)
    {
        $files = [];

        if (false !== $pos = strpos($path, '*')) {
            list($before, $after) = explode('*', $path, 2);
            $input = $this->fileLocator->locate($before).'*'.$after;

            if (false !== $paths = glob($input)) {
                foreach ($paths as $path) {
                    $files[] = $path;
                }
            }
        } else {
            $files = [$this->fileLocator->locate($path)];
        }

        return $files;
    }
46626
public function getDirectoryListing($path='/')
    {
        // 1. find out what is mounted on this path
        $listing = array();
        foreach($this->nodes as $node) {
            $mp = $node->getMountPoint();
            if ((dirname($mp) == $path) && ($path != '/')) {
                $listing[] = basename($mp)."/";
            }
            if (strncmp($path, $mp, strlen($mp)) === 0) {
                $listing = array_merge($listing, $node->getDirectoryListing($path));
            }
        }
        
        return $listing;
    }
554953
protected function _findPath($path)
    {
        $path = $this->_unifyPath($path);
        $dirs = $this->_dirs;

        $file = null;

        foreach ($dirs as $dir) {
            if (is_readable(realpath($dir.DS.$path))) {
                $file = $dir.DS.$path;
                break;
            }
        }

        return $file;
    }