(CenterFileHeader header)
| 399 | } |
| 400 | |
| 401 | private void writeCentralFileHeader(CenterFileHeader header) throws IOException { |
| 402 | boolean needZip64 = header.needZip64(); |
| 403 | byte[] extra; |
| 404 | if (needZip64) { |
| 405 | byte[] data = new byte[3 * 8]; |
| 406 | ZipUtil.writeLong(data, 0, header.size); |
| 407 | ZipUtil.writeLong(data, 8, header.compressedSize); |
| 408 | ZipUtil.writeLong(data, 16, header.headerOffset); |
| 409 | extra = ExtraDataRecord.set(header.extra, ZIP64_EXTENDED_INFO_HEADER_ID, data); |
| 410 | } else { |
| 411 | extra = ExtraDataRecord.remove(header.extra, ZIP64_EXTENDED_INFO_HEADER_ID); |
| 412 | } |
| 413 | |
| 414 | _writeInt(CFH_SIG); |
| 415 | _writeShort(Math.max(20, header.version())); |
| 416 | _writeShort(header.version()); |
| 417 | _writeShort(header.generalPurposeFlag); |
| 418 | _writeShort(header.method); |
| 419 | _writeInt(header.time); |
| 420 | _writeInt(header.crc); |
| 421 | if (needZip64) { |
| 422 | _writeUInt(MAX_ZIP_ENTRY_AND_ARCHIVE_SIZE); |
| 423 | _writeUInt(MAX_ZIP_ENTRY_AND_ARCHIVE_SIZE); |
| 424 | } else { |
| 425 | _writeUInt(header.compressedSize); |
| 426 | _writeUInt(header.size); |
| 427 | } |
| 428 | _writeShort(header.name.length); |
| 429 | _writeShort(extra.length); |
| 430 | _writeShort(header.comment.length); |
| 431 | _writeShort(header.diskNumberStart); |
| 432 | _writeShort(header.internalAttributes); |
| 433 | _writeInt(header.externalAttributes); |
| 434 | if (needZip64) { |
| 435 | _writeUInt(MAX_ZIP_ENTRY_AND_ARCHIVE_SIZE); |
| 436 | } else { |
| 437 | _writeUInt(header.headerOffset); |
| 438 | } |
| 439 | _writeBytes(header.name); |
| 440 | _writeBytes(extra); |
| 441 | _writeBytes(header.comment); |
| 442 | } |
| 443 | |
| 444 | private void writeCentralDirectoryEnd(long cdSize, long cdOffset) throws IOException { |
| 445 | if (headers.size() >= 0xffff) { |
no test coverage detected