summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorBill Marquette <billm@pfsense.org>2005-03-16 17:11:23 +0000
committerBill Marquette <billm@pfsense.org>2005-03-16 17:11:23 +0000
commit6f2e9d7f6e8c14756b94303642f3cd6921ef1052 (patch)
tree007e2e4d284e81d6d5ff8400a88455a3a0389906 /etc
parentbebb9d4d5432fd0480830970dba279d7fd226e74 (diff)
downloadpfsense-6f2e9d7f6e8c14756b94303642f3cd6921ef1052.zip
pfsense-6f2e9d7f6e8c14756b94303642f3cd6921ef1052.tar.gz
add rm -rf equivalency function - more cleanup can now commence :)
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/pfsense-utils.inc19
1 files changed, 19 insertions, 0 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index f5a40f0..986dee5 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -907,4 +907,23 @@ function make_dirs($path, $mode = 0755)
{
return is_dir($path) || (make_dirs(dirname($path), $mode) && mkdir($path, $mode));
}
+
+/*
+ * rmdirRecursive($path,$followLinks=false)
+ * Recursively remove a directory tree (rm -rf path)
+ * This is for directories _only_
+ */
+function rmdir_recursive($path,$follow_links=false) {
+ $dir = opendir($path) ;
+
+ while ($entry = readdir($dir)) {
+ if (is_file("$path/$entry") || ((!$follow_links) && is_link("$path/$entry")))
+ unlink("$path/$entry");
+ elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..')
+ rmdir_recursive("$path/$entry");
+ }
+ closedir($dir) ;
+ return rmdir($path);
+}
+
?>
OpenPOWER on IntegriCloud