From: janw Date: Fri, 3 Jun 2005 13:32:52 +0000 (+0000) Subject: clean_smarty_compile_dir works now for dirs, too X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d0eb6cfbdbc7fcabe7de28b769da163e5f609610;p=gosa.git clean_smarty_compile_dir works now for dirs, too git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@593 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/functions.inc b/include/functions.inc index 4e8434a82..53263f3b7 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -1621,6 +1621,18 @@ function dummy_error_handler() { } +function rmdirRecursive($path, $followLinks=false) { + $dir= opendir($path); + while($entry= readdir($dir)) { + if(is_file($path."/".$entry) || ((!$followLinks) && is_link($path."/".$entry))) { + unlink($path."/".$entry); + } elseif (is_dir($path."/".$entry) && $entry!='.' && $entry!='..') { + rmdirRecursive($path."/".$entry); + } + } + closedir($dir); + return rmdir($path); +} function clean_smarty_compile_dir($directory) { @@ -1646,8 +1658,14 @@ function clean_smarty_compile_dir($directory) if(!unlink($directory."/".$file)) { // This should never be reached } + } elseif(is_dir($directory."/".$file) && + is_writable($directory."/".$file)) { + // Just recursively delete it + rmdirRecursive($directory."/".$file); } } + // We should now create a fresh revision file + clean_smarty_compile_dir($directory); } else { // Revision matches, nothing to do }