From 6f2e9d7f6e8c14756b94303642f3cd6921ef1052 Mon Sep 17 00:00:00 2001 From: Bill Marquette Date: Wed, 16 Mar 2005 17:11:23 +0000 Subject: add rm -rf equivalency function - more cleanup can now commence :) --- etc/inc/pfsense-utils.inc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'etc') 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); +} + ?> -- cgit v1.1