home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / java / util / zip / ZipFileInputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  1.7 KB  |  82 lines

  1. package java.util.zip;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5.  
  6. class ZipFileInputStream extends InputStream implements ZipConstants {
  7.    // $FF: renamed from: zf java.util.zip.ZipFile
  8.    private ZipFile field_0;
  9.    // $FF: renamed from: ze java.util.zip.ZipEntry
  10.    private ZipEntry field_1;
  11.    private long pos;
  12.    private long count;
  13.  
  14.    ZipFileInputStream(ZipFile var1, ZipEntry var2) throws IOException {
  15.       this.field_0 = var1;
  16.       this.field_1 = var2;
  17.       this.readLOC();
  18.    }
  19.  
  20.    public int available() {
  21.       return (int)Math.min(this.count, 2147483647L);
  22.    }
  23.  
  24.    public int read(byte[] var1, int var2, int var3) throws IOException {
  25.       if (this.count == 0L) {
  26.          return -1;
  27.       } else {
  28.          if ((long)var3 > this.count) {
  29.             var3 = (int)Math.min(this.count, 2147483647L);
  30.          }
  31.  
  32.          var3 = this.field_0.read(this.pos, var1, var2, var3);
  33.          if (var3 == -1) {
  34.             throw new ZipException("premature EOF");
  35.          } else {
  36.             this.pos += (long)var3;
  37.             this.count -= (long)var3;
  38.             return var3;
  39.          }
  40.       }
  41.    }
  42.  
  43.    public int read() throws IOException {
  44.       if (this.count == 0L) {
  45.          return -1;
  46.       } else {
  47.          int var1 = this.field_0.read(this.pos);
  48.          if (var1 == -1) {
  49.             throw new ZipException("premature EOF");
  50.          } else {
  51.             ++this.pos;
  52.             --this.count;
  53.             return var1;
  54.          }
  55.       }
  56.    }
  57.  
  58.    public long skip(long var1) {
  59.       if (var1 > this.count) {
  60.          var1 = this.count;
  61.       }
  62.  
  63.       this.pos += var1;
  64.       this.count -= var1;
  65.       return var1;
  66.    }
  67.  
  68.    private void readLOC() throws IOException {
  69.       byte[] var1 = new byte[30];
  70.       this.field_0.read(this.field_1.offset, var1, 0, 30);
  71.       if (ZipFile.get32(var1, 0) != 67324752L) {
  72.          throw new ZipException("invalid LOC header signature");
  73.       } else {
  74.          this.count = this.field_1.csize;
  75.          this.pos = this.field_1.offset + 30L + (long)ZipFile.get16(var1, 26) + (long)ZipFile.get16(var1, 28);
  76.          if (this.pos + this.count > this.field_0.cenpos) {
  77.             throw new ZipException("invalid LOC header format");
  78.          }
  79.       }
  80.    }
  81. }
  82.