+2000-08-20 Mark Wielaard <mark@klomp.org>
+
+ * java/util/zip/Adler32.java: Make private variables really private
+ * java/util/zip/CRC32.java: Make private variables really private
+ * java/util/zip/CheckedInputStream.java: skip() could skip to much bytes
+ * java/util/zip/InflaterInputStream.java: skip() could skip to much bytes
+ * java/util/zip/ZipEntry.java: setCompressedSize() didn't check input
+ * java/util/zip/ZipFile.java: size() new 1.2 method
+ * java/util/zip/ZipInputStream.java: Use createZipEntry not new ZipEntry.
+ since 1.2 available() always returns just 1 or 0 when closed
+
Sun Aug 20 12:33:43 2000 Anthony Green <green@redhat.com>
* java/util/jar/JarFile.java: Don't call
{
private static int BASE = 65521; /* largest prime smaller than 65536 */
- int s1;
- int s2;
+ private int s1;
+ private int s2;
public Adler32 ()
{
public class CRC32 implements Checksum
{
- int crc = 0;
+ private int crc = 0;
- static int[] crc_table = make_crc_table();
+ private static int[] crc_table = make_crc_table();
/* Make the table for a fast CRC. */
static int[] make_crc_table ()
break;
n -= r;
s += r;
+ min = (int) Math.min(n, 1024);
sum.update(buf, 0, r);
}
break;
n -= r;
s += r;
+ min = (int) Math.min(n, 1024);
}
return s;
public void setCompressedSize (long compressedSize)
{
- if (size < 0 || size > 0xffffffffL)
+ if (compressedSize < 0 || compressedSize > 0xffffffffL)
throw new IllegalArgumentException ();
this.compressedSize = compressedSize;
}
public String getName () { return name; }
+ public int size () {
+ if (entries == null)
+ throw new IllegalStateException("ZipFile already closed");
+ else
+ return numEntries;
+ }
+
private int readu2 () throws IOException
{
int byte0 = file.read();
int extraLength = readu2();
byte[] bname = new byte[filenameLength];
readFully(bname);
- ZipEntry entry = new ZipEntry(new String(bname, "8859_1"));
+ ZipEntry entry = createZipEntry(new String(bname, "8859_1"));
if (extraLength > 0)
{
byte[] bextra = new byte[extraLength];
return count;
}
+ public int available() {
+ if (closed)
+ return 0;
+ else
+ return 1;
+ }
+
private void readFully (byte[] b) throws IOException
{
int off = 0;
public void close () throws IOException
{
current = null;
+ closed = true;
super.close();
}
private int avail;
// Number of bytes we can read from underlying stream.
private int compressed_bytes;
+ // Is this ZipInputStream closed? Set by the close() method.
+ private boolean closed = false;
}