Fix issue #1238
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 6e8a4de..3a373ef 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -121,11 +121,13 @@
  *
  * @param	string	path to file
  * @param	bool	whether to delete any directories found in the path
+ * @param	int
+ * @param	bool	whether to skip deleting .htaccess and index page files
  * @return	bool
  */
 if ( ! function_exists('delete_files'))
 {
-	function delete_files($path, $del_dir = FALSE, $level = 0)
+	function delete_files($path, $del_dir = FALSE, $level = 0, $htdocs = FALSE)
 	{
 		// Trim the trailing slash
 		$path = rtrim($path, DIRECTORY_SEPARATOR);
@@ -141,9 +143,9 @@
 			{
 				if (is_dir($path.DIRECTORY_SEPARATOR.$filename) && $filename[0] !== '.')
 				{
-					delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1);
+					delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1, $htdocs);
 				}
-				else
+				elseif ($htdocs === TRUE && ! preg_match('/^(\.htaccess|index\.(html|htm|php))$/', $filename))
 				{
 					@unlink($path.DIRECTORY_SEPARATOR.$filename);
 				}