Prevent warnings when reading the directory fails

(There will still be error messages)
pull/4/head
Frode Petterson 2015-10-14 14:43:03 +02:00
parent cb8640195e
commit ee02f08bdb
1 changed files with 13 additions and 10 deletions

View File

@ -1578,16 +1578,19 @@ Class H5PExport {
*/
private static function populateFileList($dir, &$files, $relative = '') {
$strip = strlen($dir) + 1;
foreach (glob($dir . DIRECTORY_SEPARATOR . '*') as $file) {
$rel = $relative . substr($file, $strip);
if (is_dir($file)) {
self::populateFileList($file, $files, $rel . '/');
}
else {
$files[] = (object) array(
'absolutePath' => $file,
'relativePath' => $rel
);
$contents = glob($dir . DIRECTORY_SEPARATOR . '*');
if (!empty($contents)) {
foreach ($contents as $file) {
$rel = $relative . substr($file, $strip);
if (is_dir($file)) {
self::populateFileList($file, $files, $rel . '/');
}
else {
$files[] = (object) array(
'absolutePath' => $file,
'relativePath' => $rel
);
}
}
}
}