delete_dir_contents function now allows excluding a dir

This commit is contained in:
stronk7
2003-08-03 00:40:08 +00:00
parent 642ac84855
commit 35ea159433
+4 -3
View 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 = "/";
@@ -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;
}
}