From: hickert Date: Tue, 14 Jun 2005 05:45:18 +0000 (+0000) Subject: Added alternative function for scandir( PHP 5 ), called scandir_php4. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4e6c2123304674b7e0dd14c489f0c53607c31507;p=gosa.git Added alternative function for scandir( PHP 5 ), called scandir_php4. For full php4 compliance git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@702 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/functions.inc b/include/functions.inc index d6ddf0694..b91a3068e 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -1635,6 +1635,39 @@ function rmdirRecursive($path, $followLinks=false) { return rmdir($path); } +function scandir_php4($path,$sort_desc=false) +{ +$ret = false; + +/* is this a dir ? */ +if(is_dir($path)) { + + /* is this path a readable one */ + if(is_readable($path)){ + + /* Get contents and write it into an array */ + $ret = array(); + + $dir = opendir($path); + + /* Is this a correct result ?*/ + if($dir){ + while($fp = readdir($dir)) + $ret[]= $fp; + } + } + } + /* Sort array ascending , like scandir */ + sort($ret); + + /* Sort descending if parameter is sort_desc is set */ + if($sort_desc) { + $ret = array_reverse($ret); + } + + return($ret); +} + function clean_smarty_compile_dir($directory) { global $svn_revision; @@ -1652,7 +1685,7 @@ function clean_smarty_compile_dir($directory) # contents should match the revision number if(!compare_revision($revision_file, $svn_revision)){ // If revision differs, clean compile directory - foreach(scandir($directory) as $file) { + foreach(scandir_php4($directory) as $file) { if( is_file($directory."/".$file) && is_writable($directory."/".$file)) { // delete file