added opendir() error handling

This commit is contained in:
following
2013-04-11 20:38:02 +02:00
parent d94c597a71
commit 0706038396
3 changed files with 21 additions and 16 deletions

View File

@@ -51,7 +51,9 @@ function smarty_core_rm_auto($params, &$smarty)
$_res = smarty_core_rmdir($_params, $smarty);
} else {
// remove matching file names
$_handle = opendir($params['auto_base']);
$_res = false;
if ($_handle = opendir($params['auto_base']))
{
$_res = true;
while (false !== ($_filename = readdir($_handle))) {
if($_filename == '.' || $_filename == '..') {
@@ -62,6 +64,7 @@ function smarty_core_rm_auto($params, &$smarty)
}
}
}
}
return $_res;
}

View File

@@ -164,7 +164,8 @@ if (substr($folder,-1) != '/')
}
$fileList = array();
$handle = opendir($folder);
if ($handle = opendir($folder))
{
while (false !== ($file = readdir($handle)))
{
if (is_file($file))
@@ -177,6 +178,7 @@ while (false !== ($file = readdir($handle)))
}
}
closedir($handle);
}
if (count($fileList) > 0)
{

View File

@@ -1065,7 +1065,7 @@ function unlinkrecursiv($path)
$notunlinked = 0;
$hDir = opendir($path);
if ($hDir === FALSE)
if ($hDir === false)
++$notunlinked;
else
{