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

Print this page




 565         long uctime = -1;
 566         if (e.mtime != null) {
 567             flagEXTT |= EXTT_FLAG_LMT;
 568             umtime = fileTimeToUnixTime(e.mtime);
 569         }
 570         if (e.atime != null) {
 571             flagEXTT |= EXTT_FLAG_LAT;
 572             uatime = fileTimeToUnixTime(e.atime);
 573         }
 574         if (e.ctime != null) {
 575             flagEXTT |= EXTT_FLAT_CT;
 576             uctime = fileTimeToUnixTime(e.ctime);
 577         }
 578         if (flagEXTT != 0) {
 579             // to use ntfs time if any m/a/ctime is beyond unixtime upper bound
 580             if (umtime > UPPER_UNIXTIME_BOUND ||
 581                 uatime > UPPER_UNIXTIME_BOUND ||
 582                 uctime > UPPER_UNIXTIME_BOUND) {
 583                 elen += 36;         // NTFS time total 36 bytes
 584             } else {
 585                 elen += 9;          // headid(2) + sz(2) + flag(1) + mtime (4)


 586             }
 587         }
 588         writeShort(elen);
 589         byte[] commentBytes;
 590         if (e.comment != null) {
 591             commentBytes = zc.getBytes(e.comment);
 592             writeShort(Math.min(commentBytes.length, 0xffff));
 593         } else {
 594             commentBytes = null;
 595             writeShort(0);
 596         }
 597         writeShort(0);              // starting disk number
 598         writeShort(0);              // internal file attributes (unused)
 599         writeInt(0);                // external file attributes (unused)
 600         writeInt(offset);           // relative offset of local header
 601         writeBytes(nameBytes, 0, nameBytes.length);
 602 
 603         // take care of EXTID_ZIP64 and EXTID_EXTT
 604         if (hasZip64) {
 605             writeShort(ZIP64_EXTID);// Zip64 extra




 565         long uctime = -1;
 566         if (e.mtime != null) {
 567             flagEXTT |= EXTT_FLAG_LMT;
 568             umtime = fileTimeToUnixTime(e.mtime);
 569         }
 570         if (e.atime != null) {
 571             flagEXTT |= EXTT_FLAG_LAT;
 572             uatime = fileTimeToUnixTime(e.atime);
 573         }
 574         if (e.ctime != null) {
 575             flagEXTT |= EXTT_FLAT_CT;
 576             uctime = fileTimeToUnixTime(e.ctime);
 577         }
 578         if (flagEXTT != 0) {
 579             // to use ntfs time if any m/a/ctime is beyond unixtime upper bound
 580             if (umtime > UPPER_UNIXTIME_BOUND ||
 581                 uatime > UPPER_UNIXTIME_BOUND ||
 582                 uctime > UPPER_UNIXTIME_BOUND) {
 583                 elen += 36;         // NTFS time total 36 bytes
 584             } else {
 585                 elen += 5;          // headid(2) + sz(2) + flag(1)
 586                 if (e.mtime != null)
 587                     elen += 4;      // + mtime (4)
 588             }
 589         }
 590         writeShort(elen);
 591         byte[] commentBytes;
 592         if (e.comment != null) {
 593             commentBytes = zc.getBytes(e.comment);
 594             writeShort(Math.min(commentBytes.length, 0xffff));
 595         } else {
 596             commentBytes = null;
 597             writeShort(0);
 598         }
 599         writeShort(0);              // starting disk number
 600         writeShort(0);              // internal file attributes (unused)
 601         writeInt(0);                // external file attributes (unused)
 602         writeInt(offset);           // relative offset of local header
 603         writeBytes(nameBytes, 0, nameBytes.length);
 604 
 605         // take care of EXTID_ZIP64 and EXTID_EXTT
 606         if (hasZip64) {
 607             writeShort(ZIP64_EXTID);// Zip64 extra