[Arakhnę-Dev] [268] * Add functions to zip or unzip folders.

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 268
Author:   galland
Date:     2011-08-22 10:47:00 +0200 (Mon, 22 Aug 2011)
Log Message:
-----------
* Add functions to zip or unzip folders.

Modified Paths:
--------------
    trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java

Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java	2011-08-22 08:03:28 UTC (rev 267)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java	2011-08-22 08:47:00 UTC (rev 268)
@@ -2593,15 +2593,21 @@
 			while (zipEntry!=null) {
 				String name = zipEntry.getName();
 				File outFile = new File(output,name).getCanonicalFile();
-				FileOutputStream fos = new FileOutputStream(outFile);
-				try {
-					while ((len=zis.read(buffer))>0) {
-						fos.write(buffer, 0, len);
+				if (zipEntry.isDirectory()) {
+					outFile.mkdirs();
+				}
+				else {
+					outFile.getParentFile().mkdirs();
+					FileOutputStream fos = new FileOutputStream(outFile);
+					try {
+						while ((len=zis.read(buffer))>0) {
+							fos.write(buffer, 0, len);
+						}
 					}
+					finally {
+						fos.close();
+					}
 				}
-				finally {
-					fos.close();
-				}
 				zipEntry = zis.getNextEntry();
 			}
 		}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/