Added more explicit failure handling to list_files
This commit is contained in:
parent
e18fe295b4
commit
7a009541ce
1 changed files with 9 additions and 3 deletions
|
@ -127,10 +127,16 @@ function list_files(string $base, string $_sub_dir=""): array
|
||||||
|
|
||||||
$files = [];
|
$files = [];
|
||||||
$dir = opendir("$base/$_sub_dir");
|
$dir = opendir("$base/$_sub_dir");
|
||||||
|
if($dir===false) {
|
||||||
|
throw new SCoreException("Unable to open directory $base/$_sub_dir");
|
||||||
|
}
|
||||||
|
try {
|
||||||
while ($f = readdir($dir)) {
|
while ($f = readdir($dir)) {
|
||||||
$files[] = $f;
|
$files[] = $f;
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
closedir($dir);
|
closedir($dir);
|
||||||
|
}
|
||||||
sort($files);
|
sort($files);
|
||||||
|
|
||||||
foreach ($files as $filename) {
|
foreach ($files as $filename) {
|
||||||
|
|
Reference in a new issue