< prev index next >

src/java.base/share/classes/java/util/zip/ZipInputStream.java

Print this page
rev 11478 : 8073497: Lazy conversion of ZipEntry time
Reviewed-by: TBD


 286         flag = get16(tmpbuf, LOCFLG);
 287         // get the entry name and create the ZipEntry first
 288         int len = get16(tmpbuf, LOCNAM);
 289         int blen = b.length;
 290         if (len > blen) {
 291             do {
 292                 blen = blen * 2;
 293             } while (len > blen);
 294             b = new byte[blen];
 295         }
 296         readFully(b, 0, len);
 297         // Force to use UTF-8 if the EFS bit is ON, even the cs is NOT UTF-8
 298         ZipEntry e = createZipEntry(((flag & EFS) != 0)
 299                                     ? zc.toStringUTF8(b, len)
 300                                     : zc.toString(b, len));
 301         // now get the remaining fields for the entry
 302         if ((flag & 1) == 1) {
 303             throw new ZipException("encrypted ZIP entry not supported");
 304         }
 305         e.method = get16(tmpbuf, LOCHOW);
 306         e.time = dosToJavaTime(get32(tmpbuf, LOCTIM));
 307         if ((flag & 8) == 8) {
 308             /* "Data Descriptor" present */
 309             if (e.method != DEFLATED) {
 310                 throw new ZipException(
 311                         "only DEFLATED entries can have EXT descriptor");
 312             }
 313         } else {
 314             e.crc = get32(tmpbuf, LOCCRC);
 315             e.csize = get32(tmpbuf, LOCSIZ);
 316             e.size = get32(tmpbuf, LOCLEN);
 317         }
 318         len = get16(tmpbuf, LOCEXT);
 319         if (len > 0) {
 320             byte[] extra = new byte[len];
 321             readFully(extra, 0, len);
 322             e.setExtra0(extra,
 323                         e.csize == ZIP64_MAGICVAL || e.size == ZIP64_MAGICVAL);
 324         }
 325         return e;
 326     }




 286         flag = get16(tmpbuf, LOCFLG);
 287         // get the entry name and create the ZipEntry first
 288         int len = get16(tmpbuf, LOCNAM);
 289         int blen = b.length;
 290         if (len > blen) {
 291             do {
 292                 blen = blen * 2;
 293             } while (len > blen);
 294             b = new byte[blen];
 295         }
 296         readFully(b, 0, len);
 297         // Force to use UTF-8 if the EFS bit is ON, even the cs is NOT UTF-8
 298         ZipEntry e = createZipEntry(((flag & EFS) != 0)
 299                                     ? zc.toStringUTF8(b, len)
 300                                     : zc.toString(b, len));
 301         // now get the remaining fields for the entry
 302         if ((flag & 1) == 1) {
 303             throw new ZipException("encrypted ZIP entry not supported");
 304         }
 305         e.method = get16(tmpbuf, LOCHOW);
 306         e.time = get32(tmpbuf, LOCTIM);
 307         if ((flag & 8) == 8) {
 308             /* "Data Descriptor" present */
 309             if (e.method != DEFLATED) {
 310                 throw new ZipException(
 311                         "only DEFLATED entries can have EXT descriptor");
 312             }
 313         } else {
 314             e.crc = get32(tmpbuf, LOCCRC);
 315             e.csize = get32(tmpbuf, LOCSIZ);
 316             e.size = get32(tmpbuf, LOCLEN);
 317         }
 318         len = get16(tmpbuf, LOCEXT);
 319         if (len > 0) {
 320             byte[] extra = new byte[len];
 321             readFully(extra, 0, len);
 322             e.setExtra0(extra,
 323                         e.csize == ZIP64_MAGICVAL || e.size == ZIP64_MAGICVAL);
 324         }
 325         return e;
 326     }


< prev index next >