From 9fcc28a29299fbbc242f87bf1b1e61fda6543886 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 21 Oct 2006 17:49:47 +0000 Subject: --- system/helpers/file_helper.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index c0f525688..635ef1ba0 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -110,7 +110,7 @@ function write_file($path, $data, $mode = 'wb') * @param bool whether to delete any directories found in the path * @return bool */ -function delete_files($path, $del_dir = FALSE) +function delete_files($path, $del_dir = FALSE, $level = 0) { // Trim the trailing slash $path = preg_replace("|^(.+?)/*$|", "\\1", $path); @@ -124,7 +124,8 @@ function delete_files($path, $del_dir = FALSE) { if (is_dir($path.'/'.$filename)) { - delete_files($path.'/'.$filename, $del_dir); + $level++; + delete_files($path.'/'.$filename, $del_dir, $level); } else { @@ -134,7 +135,7 @@ function delete_files($path, $del_dir = FALSE) } @closedir($current_dir); - if ($del_dir == TRUE) + if ($del_dir == TRUE AND $level > 0) { @rmdir($path); } -- cgit v1.2.3-24-g4f1b