| 638 | } |
| 639 | |
| 640 | int LoadCentralDirectoryRecord(zip64_internal* pziinit) |
| 641 | { |
| 642 | int err=ZIP_OK; |
| 643 | ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
| 644 | |
| 645 | ZPOS64_T size_central_dir; /* size of the central directory */ |
| 646 | ZPOS64_T offset_central_dir; /* offset of start of central directory */ |
| 647 | ZPOS64_T central_pos; |
| 648 | uLong uL; |
| 649 | |
| 650 | uLong number_disk; /* number of the current dist, used for |
| 651 | spaning ZIP, unsupported, always 0*/ |
| 652 | uLong number_disk_with_CD; /* number the the disk with central dir, used |
| 653 | for spaning ZIP, unsupported, always 0*/ |
| 654 | ZPOS64_T number_entry; |
| 655 | ZPOS64_T number_entry_CD; /* total number of entries in |
| 656 | the central dir |
| 657 | (same than number_entry on nospan) */ |
| 658 | uLong VersionMadeBy; |
| 659 | uLong VersionNeeded; |
| 660 | uLong size_comment; |
| 661 | |
| 662 | int hasZIP64Record = 0; |
| 663 | |
| 664 | // check first if we find a ZIP64 record |
| 665 | central_pos = zip64local_SearchCentralDir64(&pziinit->z_filefunc,pziinit->filestream); |
| 666 | if(central_pos > 0) |
| 667 | { |
| 668 | hasZIP64Record = 1; |
| 669 | } |
| 670 | else if(central_pos == 0) |
| 671 | { |
| 672 | central_pos = zip64local_SearchCentralDir(&pziinit->z_filefunc,pziinit->filestream); |
| 673 | } |
| 674 | |
| 675 | /* disable to allow appending to empty ZIP archive |
| 676 | if (central_pos==0) |
| 677 | err=ZIP_ERRNO; |
| 678 | */ |
| 679 | |
| 680 | if(hasZIP64Record) |
| 681 | { |
| 682 | ZPOS64_T sizeEndOfCentralDirectory; |
| 683 | if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos, ZLIB_FILEFUNC_SEEK_SET) != 0) |
| 684 | err=ZIP_ERRNO; |
| 685 | |
| 686 | /* the signature, already checked */ |
| 687 | if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&uL)!=ZIP_OK) |
| 688 | err=ZIP_ERRNO; |
| 689 | |
| 690 | /* size of zip64 end of central directory record */ |
| 691 | if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream, &sizeEndOfCentralDirectory)!=ZIP_OK) |
| 692 | err=ZIP_ERRNO; |
| 693 | |
| 694 | /* version made by */ |
| 695 | if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &VersionMadeBy)!=ZIP_OK) |
| 696 | err=ZIP_ERRNO; |
| 697 |
no test coverage detected