public function getFileList($dir, $baseUrl, $protectedBaseUrl = null)
    {
        $results = [];

        if (is_dir($dir)) {
            if ($handler = opendir($dir)) {
                while (false !== ($file = readdir($handler))) {
                    if ('.' == substr($file, 0, 1)) {
                        continue;
                    }

                    $fileArray = [];
                    $fileArray['filename'] = htmlentities($file);

                    if ($protectedBaseUrl) {
                        $fileArray['absUrl'] =
                            $protectedBaseUrl.(empty($_GET) ? '?' : '&').'file='.str_replace('//', '', $baseUrl.'/'.$file);
                    } else {
                        $fileArray['absUrl'] = str_replace('\\', '/', str_replace('//', '', $baseUrl.'/'.$file));
                    }

                    $fileArray['path'] = str_replace($fileArray['filename'], '', $fileArray['absUrl']);
                    $fileArray['filesize'] =
                        $this->formatSizeUnits(filesize(str_replace('\\', '/', str_replace('//', '', $dir.'/'.$file))), true);

                    $results[] = $fileArray;
                }

                closedir($handler);
            }
        }

        $this->container->get('huh.utils.array')->aasort($results, 'filename');

        return $results;
    }