FOF30\Download\Download::scanDirectory PHP Méthode

scanDirectory() protected static méthode

Recursive function that will scan every directory unless it's in the ignore list. Files that aren't in the ignore list are returned.
protected static scanDirectory ( string $path, array $ignoreFolders = [], array $ignoreFiles = [] ) : array
$path string Folder where we should start looking
$ignoreFolders array Folder ignore list
$ignoreFiles array File ignore list
Résultat array List of all the files
    protected static function scanDirectory($path, array $ignoreFolders = array(), array $ignoreFiles = array())
    {
        $return = array();
        $handle = @opendir($path);
        if (!$handle) {
            return $return;
        }
        while (($file = readdir($handle)) !== false) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            $fullpath = $path . '/' . $file;
            if (is_dir($fullpath) && in_array($file, $ignoreFolders) || is_file($fullpath) && in_array($file, $ignoreFiles)) {
                continue;
            }
            if (is_dir($fullpath)) {
                $return = array_merge(self::scanDirectory($fullpath, $ignoreFolders, $ignoreFiles), $return);
            } else {
                $return[] = $path . '/' . $file;
            }
        }
        return $return;
    }