On Mon, 2006-04-03 at 18:57 -0600, Tom Tromey wrote:

> Return 'sz' doesn't seem to be correct after the caller has read some
> bytes.  It is only correct the first time.  I think you want
> something like:
> 
>   final Inflater inf = new Inflater(true);
>   return new InflaterInputStream(....) { ....
>      return sz - inf.getTotalOut();
> 
> What do you think?

Yes, you are right. Thanks for pointing this out.

2006-04-04  Lillian Angel  <[EMAIL PROTECTED]>

        * java/util/zip/ZipFile.java
        (getInputStream): Fixed to return size of ZipEntry
        minus the total bytes read. This guarantees that the
        right value is returned even if some bytes have already
        been read.

Index: java/util/zip/ZipFile.java
===================================================================
RCS file: /sources/classpath/classpath/java/util/zip/ZipFile.java,v
retrieving revision 1.31
diff -u -r1.31 ZipFile.java
--- java/util/zip/ZipFile.java	3 Apr 2006 20:50:38 -0000	1.31
+++ java/util/zip/ZipFile.java	4 Apr 2006 14:03:12 -0000
@@ -445,13 +445,14 @@
       case ZipOutputStream.STORED:
 	return inp;
       case ZipOutputStream.DEFLATED:
+        final Inflater inf = new Inflater(true);
         final int sz = (int) entry.getSize();
-        return new InflaterInputStream(inp, new Inflater(true))
+        return new InflaterInputStream(inp, inf)
         {
           public int available() throws IOException
           {
             if (super.available() != 0)
-              return sz;
+              return sz - inf.getTotalOut();
             return 0;
           }
         };

Reply via email to