- while (($file = $d->read()) !== false) {
- list($path, $name, $ext) = $this->splitFilename("$root/$file");
- if (is_readable("$root/$file") and in_array($ext, $exts)) {
- $thumb = $this->getThumbFilename("$root/$file");
- $return[] = array(
- 'file' => "$root/$file",
- 'desc' => $name,
- 'thumb' => is_readable($thumb) ? $thumb : null,
- );
- }
+ if ($d) {
+ while (($file = $d->read()) !== false) {
+ list($path, $name, $ext) = $this->splitFilename("$root/$file");
+ if (is_readable("$root/$file") and in_array($ext, $exts)) {
+ $thumb = $this->getThumbFilename("$root/$file");
+ $return[] = array(
+ 'file' => "$root/$name",
+ 'desc' => $name,
+ 'thumb' => is_readable($thumb) ? $thumb : null,
+ );
+ }
+ }
+ $d->close();