From: stronk7 Date: Sun, 3 Aug 2003 00:40:08 +0000 (+0000) Subject: delete_dir_contents function now allows excluding a dir X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=35ea159433eb57c78d9346bee8aa44510491a04b;p=moodle.git delete_dir_contents function now allows excluding a dir --- diff --git a/backup/lib.php b/backup/lib.php index 9bc0c6c015..8276bbf7fc 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -92,8 +92,9 @@ } //Function to delete all the directory contents recursively + //it supports a excluded dit too //Copied from the web !! - function delete_dir_contents ($dir) { + function delete_dir_contents ($dir,$excludeddir="") { $slash = "/"; @@ -111,10 +112,10 @@ // Loop through all directory entries, and construct two temporary arrays containing files and sub directories while($entry = readdir($handle)) { - if (is_dir($dir. $slash .$entry) && $entry != ".." && $entry != ".") { + if (is_dir($dir. $slash .$entry) && $entry != ".." && $entry != "." && $entry != $excludeddir) { $dir_subdirs[] = $dir. $slash .$entry; } - else if ($entry != ".." && $entry != ".") { + else if ($entry != ".." && $entry != "." && $entry != $excludeddir) { $dir_files[] = $dir. $slash .$entry; } }