jdk/src/java.base/share/classes/java/util/zip/ZipFile.java
changeset 32993 fa6bbf6ed92b
parent 32834 e1dca5fe4de3
child 34525 14d2d84cae6d
equal deleted inserted replaced
32992:19ed8781c2ba 32993:fa6bbf6ed92b
    58  *
    58  *
    59  * @author      David Connelly
    59  * @author      David Connelly
    60  */
    60  */
    61 public
    61 public
    62 class ZipFile implements ZipConstants, Closeable {
    62 class ZipFile implements ZipConstants, Closeable {
    63     private long jzfile;           // address of jzfile data
    63     private long jzfile;  // address of jzfile data
    64     private final String name;     // zip file name
    64     private final String name;     // zip file name
    65     private final int total;       // total number of entries
    65     private final int total;       // total number of entries
    66     private final boolean locsig;  // if zip file starts with LOCSIG (usually true)
    66     private final boolean locsig;  // if zip file starts with LOCSIG (usually true)
    67     private volatile boolean closeRequested = false;
    67     private volatile boolean closeRequested = false;
    68 
    68 
   689     /*
   689     /*
   690      * Inner class implementing the input stream used to read a
   690      * Inner class implementing the input stream used to read a
   691      * (possibly compressed) zip file entry.
   691      * (possibly compressed) zip file entry.
   692      */
   692      */
   693    private class ZipFileInputStream extends InputStream {
   693    private class ZipFileInputStream extends InputStream {
   694         private volatile boolean closeRequested = false;
   694         private volatile boolean zfisCloseRequested = false;
   695         protected long jzentry; // address of jzentry data
   695         protected long jzentry; // address of jzentry data
   696         private   long pos;     // current position within entry data
   696         private   long pos;     // current position within entry data
   697         protected long rem;     // number of remaining bytes within entry
   697         protected long rem;     // number of remaining bytes within entry
   698         protected long size;    // uncompressed size of this entry
   698         protected long size;    // uncompressed size of this entry
   699 
   699 
   716                 }
   716                 }
   717                 if (len > rem) {
   717                 if (len > rem) {
   718                     len = (int) rem;
   718                     len = (int) rem;
   719                 }
   719                 }
   720 
   720 
       
   721                 // Check if ZipFile open
   721                 ensureOpenOrZipException();
   722                 ensureOpenOrZipException();
   722                 len = ZipFile.read(ZipFile.this.jzfile, jzentry, pos, b,
   723                 len = ZipFile.read(ZipFile.this.jzfile, jzentry, pos, b,
   723                                    off, len);
   724                                    off, len);
   724                 if (len > 0) {
   725                 if (len > 0) {
   725                     this.pos = (pos + len);
   726                     this.pos = (pos + len);
   759         public long size() {
   760         public long size() {
   760             return size;
   761             return size;
   761         }
   762         }
   762 
   763 
   763         public void close() {
   764         public void close() {
   764             if (closeRequested)
   765             if (zfisCloseRequested)
   765                 return;
   766                 return;
   766             closeRequested = true;
   767             zfisCloseRequested = true;
   767 
   768 
   768             rem = 0;
   769             rem = 0;
   769             synchronized (ZipFile.this) {
   770             synchronized (ZipFile.this) {
   770                 if (jzentry != 0 && ZipFile.this.jzfile != 0) {
   771                 if (jzentry != 0 && ZipFile.this.jzfile != 0) {
   771                     freeEntry(ZipFile.this.jzfile, jzentry);
   772                     freeEntry(ZipFile.this.jzfile, jzentry);