harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjanu...@apache.org
Subject svn commit: r738855 - /harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java
Date Thu, 29 Jan 2009 13:27:39 GMT
Author: sjanuary
Date: Thu Jan 29 13:27:38 2009
New Revision: 738855

URL: http://svn.apache.org/viewvc?rev=738855&view=rev
Log:
Unpack200 - Fix bug where Jar entries were always deflated instead of obeying settings

Modified:
    harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java

Modified: harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java?rev=738855&r1=738854&r2=738855&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/pack200/src/main/java/org/apache/harmony/unpack200/Segment.java
Thu Jan 29 13:27:38 2009
@@ -31,6 +31,7 @@
 import java.util.TimeZone;
 import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
+import java.util.zip.CRC32;
 import java.util.zip.GZIPInputStream;
 import java.util.zip.ZipEntry;
 
@@ -528,7 +529,6 @@
         long[] fileSize = fileBands.getFileSize();
         byte[][] fileBits = fileBands.getFileBits();
 
-        // out.setLevel(JarEntry.DEFLATED)
         // now write the files out
         int classNum = 0;
         int numberOfFiles = header.getNumberOfFiles();
@@ -546,23 +546,32 @@
             boolean deflate = fileDeflate[i];
 
             JarEntry entry = new JarEntry(name);
-            if (deflate)
+            if (deflate) {
                 entry.setMethod(ZipEntry.DEFLATED);
+            } else {
+                entry.setMethod(ZipEntry.STORED);
+                CRC32 crc = new CRC32();
+                if(fileIsClass[i]) {
+                    crc.update(classFilesContents[classNum]);
+                    entry.setSize(classFilesContents[classNum].length);
+                } else {
+                    crc.update(fileBits[i]);
+                    entry.setSize(fileSize[i]);
+                }
+                entry.setCrc(crc.getValue());
+            }
             // On Windows at least, need to correct for timezone
             entry.setTime(modtime - TimeZone.getDefault().getRawOffset());
             out.putNextEntry(entry);
 
+            // write to output stream
             if (fileIsClass[i]) {
-                // write to dos
                 entry.setSize(classFilesContents[classNum].length);
                 out.write(classFilesContents[classNum]);
                 classNum++;
             } else {
-                long size = fileSize[i];
-                entry.setSize(size);
-
-                byte[] data = fileBits[i];
-                out.write(data);
+                entry.setSize(fileSize[i]);
+                out.write(fileBits[i]);
             }
         }
     }



Mime
View raw message