Skip to content

Commit

Permalink
delete_dir_contents function now allows excluding a dir
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Aug 3, 2003
1 parent 642ac84 commit 35ea159
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions backup/lib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ function check_and_create_backup_dir($backup_unique_code) {
} }


//Function to delete all the directory contents recursively //Function to delete all the directory contents recursively
//it supports a excluded dit too
//Copied from the web !! //Copied from the web !!
function delete_dir_contents ($dir) { function delete_dir_contents ($dir,$excludeddir="") {


$slash = "/"; $slash = "/";


Expand All @@ -111,10 +112,10 @@ function delete_dir_contents ($dir) {


// Loop through all directory entries, and construct two temporary arrays containing files and sub directories // Loop through all directory entries, and construct two temporary arrays containing files and sub directories
while($entry = readdir($handle)) { 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; $dir_subdirs[] = $dir. $slash .$entry;
} }
else if ($entry != ".." && $entry != ".") { else if ($entry != ".." && $entry != "." && $entry != $excludeddir) {
$dir_files[] = $dir. $slash .$entry; $dir_files[] = $dir. $slash .$entry;
} }
} }
Expand Down

0 comments on commit 35ea159

Please sign in to comment.