Added an option to remove the preceding trail of empty folders when creating a Zip archive.
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 2c4bd25..3ba3ddc 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -270,27 +270,48 @@
 	 * @access	public
 	 * @param	string	path to source
 	 * @return	bool
-	 */	
-	function read_dir($path)
-	{	
-		if ($fp = @opendir($path))
+	 */
+	function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL)
+	{
+		if (!$fp = @opendir($path))
 		{
-			while (FALSE !== ($file = readdir($fp)))
+			return FALSE;
+		}
+
+		// Set the original directory root for child dir's to use as relative
+		if ($root_path === NULL)
+		{
+			$root_path = dirname($path).'/';
+		}
+
+		while (FALSE !== ($file = readdir($fp)))
+		{
+			if(substr($file, 0, 1) == '.')
 			{
-				if (@is_dir($path.$file) && substr($file, 0, 1) != '.')
-				{					
-					$this->read_dir($path.$file."/");
-				}
-				elseif (substr($file, 0, 1) != ".")
+				continue;
+			}
+
+			if (@is_dir($path.$file))
+			{
+				$this->read_dir($path.$file."/", $preserve_filepath, $root_path);
+			}
+
+			else
+			{
+				if (FALSE !== ($data = file_get_contents($path.$file)))
 				{
-					if (FALSE !== ($data = file_get_contents($path.$file)))
-					{						
-						$this->add_data(str_replace("\\", "/", $path).$file, $data);
+					$name = str_replace("\\", "/", $path);
+
+					if ($preserve_filepath === FALSE)
+					{
+						$name = str_replace($root_path, '', $name);
 					}
+
+					$this->add_data($name.$file, $data);
 				}
 			}
-			return TRUE;
 		}
+		return TRUE;
 	}
 
 	// --------------------------------------------------------------------
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index ae63b1f..08c9815 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -95,6 +95,7 @@
 			<li>Added a <kbd>download()</kbd> method to the <a href="libraries/ftp.html">FTP library</a></li>
 			<li>Changed <kbd>do_xss_clean()</kbd> to return FALSE if the uploaded file fails XSS checks.</li> 
 			<li>Added stripslashes() and trim()ing of double quotes from $_FILES type value to standardize input in Upload library.</li>
+			<li>Added a second parameter (boolean) to <kbd>$this->zip->read_dir('/path/to/directory', FALSE)</kbd> to remove the preceding trail of empty folders when creating a Zip archive. This example would contain a zip with "directory" and all of its contents.</li>
 		</ul>
 	</li>
 	<li>Database
diff --git a/user_guide/libraries/zip.html b/user_guide/libraries/zip.html
index 44603f2..844023b 100644
--- a/user_guide/libraries/zip.html
+++ b/user_guide/libraries/zip.html
@@ -177,7 +177,7 @@
 
 <h2>$this->zip->read_dir()</h2>
 
-<p>Permits you to compress a folder (and its contents) that already exists somewhere on your server.  Supply a file path to the 
+<p>Permits you to compress a folder (and its contents) that already exists somewhere on your server.  Supply a file path to the
 directory and the zip class will recursively read it and recreate it as a Zip archive.  All files contained within the
 supplied path will be encoded, as will any sub-folders contained within it.  Example:</p>
 
@@ -189,6 +189,16 @@
 $this->zip->download('my_backup.zip');
 </code>
 
+<p>By default the Zip archive will place all directories listed in the first parameter inside the zip. If you only want the end folder to be in the zip
+you can pass <kbd>FALSE</kbd> (boolean) in the second parameter.  Example:</p>
+
+<code>
+$path = '/path/to/your/directory/';<br /><br />
+$this->zip->read_dir($path, FALSE);
+</code>
+
+<p>This will create a ZIP with the folder "directory" inside, then all sub-folders stored correctly inside that.</p>
+