]> git.mjollnir.org Git - moodle.git/commitdiff
delete_dir_contents function now allows excluding a dir
authorstronk7 <stronk7>
Sun, 3 Aug 2003 00:40:08 +0000 (00:40 +0000)
committerstronk7 <stronk7>
Sun, 3 Aug 2003 00:40:08 +0000 (00:40 +0000)
backup/lib.php

index 9bc0c6c0158dfcfd81852c1c81e1f242255f805a..8276bbf7fcd1eac0c46bc190bc731478bc1c0849 100644 (file)
@@ -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 = "/";
 
 
         // 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;
             }
         }