[jsword-svn] r2234 - trunk/jsword/src/main/java/org/crosswire/common/util

mjdenham at crosswire.org mjdenham at crosswire.org
Wed Mar 7 12:14:34 MST 2012


Author: mjdenham
Date: 2012-03-07 12:14:34 -0700 (Wed, 07 Mar 2012)
New Revision: 2234

Modified:
   trunk/jsword/src/main/java/org/crosswire/common/util/IOUtil.java
Log:
JS-211 : Avoid writing zip dir entries out as files

Modified: trunk/jsword/src/main/java/org/crosswire/common/util/IOUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/util/IOUtil.java	2012-03-05 11:38:20 UTC (rev 2233)
+++ trunk/jsword/src/main/java/org/crosswire/common/util/IOUtil.java	2012-03-07 19:14:34 UTC (rev 2234)
@@ -80,21 +80,25 @@
                         throw new MalformedURLException(JSMsg.gettext("The URL {0} could not be created as a directory.", parentDir.toString()));
                     }
                 }
+                
+                // write entryFile from zip to filesystem but avoid writing dir entries out as files
+                if (!entry.isDirectory()) {
 
-                URI child = NetUtil.getURI(entryFile);
-
-                OutputStream dataOut = NetUtil.getOutputStream(child);
-                InputStream dataIn = zf.getInputStream(entry);
-
-                while (true) {
-                    int count = dataIn.read(dbuf);
-                    if (count == -1) {
-                        break;
+                    URI child = NetUtil.getURI(entryFile);
+    
+                    OutputStream dataOut = NetUtil.getOutputStream(child);
+                    InputStream dataIn = zf.getInputStream(entry);
+    
+                    while (true) {
+                        int count = dataIn.read(dbuf);
+                        if (count == -1) {
+                            break;
+                        }
+                        dataOut.write(dbuf, 0, count);
                     }
-                    dataOut.write(dbuf, 0, count);
+    
+                    dataOut.close();
                 }
-
-                dataOut.close();
             }
         } finally {
             IOUtil.close(zf);




More information about the jsword-svn mailing list