[Kaffe] a couple of patches for java.util.zip

Moses DeJong dejong at cs.umn.edu
Wed Feb 10 21:35:20 PST 1999


Could someone add these 1.2 style patches for java.util.zip?
The patch adds a ZipEntry constructor and the setCompressedSize()
method. It also fixes a default value bug for the time field and
a typo in the setSize() method.

mo dejong
dejong at cs.umn.edu


Index: ZipEntry.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/util/zip/ZipEntry.java,v
retrieving revision 1.3
diff -u -r1.3 ZipEntry.java
--- ZipEntry.java	1998/10/29 06:41:34	1.3
+++ ZipEntry.java	1999/02/11 06:35:01
@@ -43,7 +43,7 @@
       throw new IllegalArgumentException("name length > 0xFFFF");
     }
     name = nm;
-    time = 0;
+    time = -1;
     crc = 0;
     size = -1;
     method = -1;
@@ -52,6 +52,23 @@
     csize = -1;
   }
 
+  public ZipEntry(ZipEntry entry)
+  {
+    name = entry.name;
+    time = entry.time;
+    crc  = entry.crc;
+    size = entry.size;
+    method = entry.method;
+    extra = entry.extra;
+    comment = entry.comment;
+    csize = entry.csize;
+
+    // What are these for ???
+    //flag = entry.flag;
+    //version = entry.version;
+    //offset = entry.offset;
+  }
+
   public String getName()
   {
     return (name);
@@ -67,12 +84,12 @@
     return (time);
   }
 
-  public void setSize(long sz)
+  public void setSize(long size)
   {
-    if (size > 0xFFFFFFFF) {
-      throw new IllegalArgumentException("size > 0xFFFFFFFF");
+    if (size < 0 || size > 0xFFFFFFFFL) {
+      throw new IllegalArgumentException("size < 0 or size > 0xFFFFFFFF");
     }
-    size = sz;
+    this.size = size;
   }
 
   public long getSize()
@@ -132,6 +149,15 @@
     return (comment);
   }
 
+  public void setCompressedSize(long csize)
+  {
+    if (csize < 0 || csize > 0xFFFFFFFFL) {
+	throw new IllegalArgumentException("csize < 0 or csize > 0xFFFFFFFF");
+    }
+
+    this.csize = csize;
+  }
+  
   public long getCompressedSize()
   {
     return (csize);
Index: ZipInputStream.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/util/zip/ZipInputStream.java,v
retrieving revision 1.2
diff -u -r1.2 ZipInputStream.java
--- ZipInputStream.java	1998/10/01 17:25:48	1.2
+++ ZipInputStream.java	1999/02/11 06:35:01
@@ -48,7 +48,7 @@
       }
   
       ZipEntry entry = new ZipEntry(new String(name));
-      entry.time = 0;
+      entry.time = -1;
       entry.crc = get32(LOC_CRC);
       entry.size = (int)get32(LOC_UNCOMPRESSEDSIZE);
       entry.method = get16(LOC_METHOD);



More information about the kaffe mailing list