re PR libgcj/7766 (ZipInputStream.available returns 0 immediately after construction)
authorJesse Rosenstock <jmr@ugcs.caltech.edu>
Wed, 25 Sep 2002 20:10:42 +0000 (20:10 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Wed, 25 Sep 2002 20:10:42 +0000 (20:10 +0000)
2002-09-25  Jesse Rosenstock  <jmr@ugcs.caltech.edu>

Fix for PR libgcj/7766:
* java/util/zip/ZipInputStream.java (entryAtEOF): New field.
(getNextEntry): Set it.
(closeEntry): Likewise.
(read): Likewise.
(close): Likewise.
(available): Use it.

From-SVN: r57513

libjava/ChangeLog
libjava/java/util/zip/ZipInputStream.java

index 3132150f7ee9611b804bef872f0b780bf36f1577..b1f7f40763c292de26cebdcf592cc06e2e5af211 100644 (file)
@@ -1,3 +1,13 @@
+2002-09-25  Jesse Rosenstock  <jmr@ugcs.caltech.edu>
+
+       Fix for PR libgcj/7766:
+       * java/util/zip/ZipInputStream.java (entryAtEOF): New field.
+       (getNextEntry): Set it.
+       (closeEntry): Likewise.
+       (read): Likewise.
+       (close): Likewise.
+       (available): Use it.
+
 2002-09-25  Michael Koch  <konqueror@gmx.de>
 
        * java/net/DatagramSocket.java
index 63153b649c9e19f8c817a09e327e6defd1c81c89..710ca74c201893d6de5d72dd202a6b3644b4c0eb 100644 (file)
@@ -61,6 +61,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
   private int method;
   private int flags;
   private int avail;
+  private boolean entryAtEOF;
 
   /**
    * Creates a new Zip input stream, reading a zip archive.
@@ -150,7 +151,8 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
        return null;
       }
     if (header != LOCSIG)
-      throw new ZipException("Wrong Local header signature" + Integer.toHexString(header));
+      throw new ZipException("Wrong Local header signature"
+                            + Integer.toHexString(header));
     /* skip version */
     readLeShort();
     flags = readLeShort();
@@ -171,6 +173,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
     String name = new String(buffer);
     
     entry = createZipEntry(name);
+    entryAtEOF = false;
     entry.setMethod(method);
     if ((flags & 8) == 0)
       {
@@ -252,11 +255,12 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
     if (method == ZipOutputStream.DEFLATED)
       inf.reset();
     entry = null;
+    entryAtEOF = true;
   }
 
   public int available() throws IOException
   {
-    return entry != null ? 1 : 0;
+    return entryAtEOF ? 0 : 1;
   }
 
   /**
@@ -335,6 +339,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
          throw new ZipException("CRC mismatch");
        crc.reset();
        entry = null;
+       entryAtEOF = true;
       }
     return len;
   }
@@ -348,6 +353,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
     super.close();
     crc = null;
     entry = null;
+    entryAtEOF = true;
   }
 
   /**