Author: tmortagne
Date: 2007-12-11 17:55:44 +0100 (Tue, 11 Dec 2007)
New Revision: 6342

Modified:
   
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/export/html/HtmlPackager.java
Log:
XWIKI-564: Export pages in HTML, in a zip file
* Temporary directory created to create the zip package is not deleted.

Modified: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/export/html/HtmlPackager.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/export/html/HtmlPackager.java
      2007-12-11 16:46:05 UTC (rev 6341)
+++ 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/export/html/HtmlPackager.java
      2007-12-11 16:55:44 UTC (rev 6342)
@@ -176,9 +176,43 @@
         // Finish zip file
         zos.finish();
         zos.flush();
+
+        // Delete temporary directory
+        deleteDirectory(tempdir);
     }
 
     /**
+     * Delete a directory and all with all it's content.
+     * 
+     * @param directory the directory to delete.
+     */
+    private static void deleteDirectory(File directory)
+    {
+        if (!directory.isDirectory()) {
+            return;
+        }
+
+        File[] files = directory.listFiles();
+
+        if (files == null) {
+            return;
+        }
+
+        for (int i = 0; i < files.length; ++i) {
+            File file = files[i];
+
+            if (file.isDirectory()) {
+                deleteDirectory(file);
+                continue;
+            }
+
+            file.delete();
+        }
+
+        directory.delete();
+    }
+
+    /**
      * Add skin to the package in sub-directory "skins".
      * 
      * @param skinName the name of the skin.

_______________________________________________
notifications mailing list
notifications@xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to