summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
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