From 0cfc9a0eaaab2ae7fc8c91b9dd2e6d9a55bb9002 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Wed, 24 Sep 2014 15:17:16 +0200 Subject: [PATCH] Switch to scandir. --- src/_h5ai/server/php/inc/class-app.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/_h5ai/server/php/inc/class-app.php b/src/_h5ai/server/php/inc/class-app.php index ae1cc21d..ecbe74ad 100644 --- a/src/_h5ai/server/php/inc/class-app.php +++ b/src/_h5ai/server/php/inc/class-app.php @@ -118,18 +118,15 @@ class App { $names = array(); if (is_dir($path)) { - if ($dir = opendir($path)) { - while (($name = readdir($dir)) !== false) { - if ( - $this->is_hidden($name) - || $this->is_hidden($this->to_url($path) . $name) - || (!is_readable($path .'/'. $name) && $this->options["view"]["hideIf403"]) - ) { - continue; - } - $names[] = $name; + foreach (scandir($path) as $name) { + if ( + $this->is_hidden($name) + || $this->is_hidden($this->to_url($path) . $name) + || (!is_readable($path .'/'. $name) && $this->options["view"]["hideIf403"]) + ) { + continue; } - closedir($dir); + $names[] = $name; } } return $names;