Open a Zip file. path contain the full pathname (by example, on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer "zlib/zlib114.zip". If the zipfile cannot be opened (file doesn't exist or in not valid), the return value is NULL. Else, the return value is a unzFile Handle, usable with other function of this unzip package. */
| 578 | of this unzip package. |
| 579 | */ |
| 580 | local unzFile unzOpenInternal(const void* path, |
| 581 | zlib_filefunc64_32_def* pzlib_filefunc64_32_def, |
| 582 | int is64bitOpenFunction) |
| 583 | { |
| 584 | unz64_s us; |
| 585 | unz64_s* s; |
| 586 | ZPOS64_T central_pos; |
| 587 | uLong uL; |
| 588 | |
| 589 | uLong number_disk; /* number of the current dist, used for |
| 590 | spaning ZIP, unsupported, always 0*/ |
| 591 | uLong number_disk_with_CD; /* number the the disk with central dir, used |
| 592 | for spaning ZIP, unsupported, always 0*/ |
| 593 | ZPOS64_T number_entry_CD; /* total number of entries in |
| 594 | the central dir |
| 595 | (same than number_entry on nospan) */ |
| 596 | |
| 597 | int err = UNZ_OK; |
| 598 | |
| 599 | if (unz_copyright[0] != ' ') |
| 600 | return NULL; |
| 601 | |
| 602 | us.z_filefunc.zseek32_file = NULL; |
| 603 | us.z_filefunc.ztell32_file = NULL; |
| 604 | if (pzlib_filefunc64_32_def == NULL) |
| 605 | fill_fopen64_filefunc(&us.z_filefunc.zfile_func64); |
| 606 | else |
| 607 | us.z_filefunc = *pzlib_filefunc64_32_def; |
| 608 | us.is64bitOpenFunction = is64bitOpenFunction; |
| 609 | |
| 610 | |
| 611 | us.filestream = ZOPEN64(us.z_filefunc, |
| 612 | path, |
| 613 | ZLIB_FILEFUNC_MODE_READ | |
| 614 | ZLIB_FILEFUNC_MODE_EXISTING); |
| 615 | if (us.filestream == NULL) |
| 616 | return NULL; |
| 617 | |
| 618 | central_pos = unz64local_SearchCentralDir64(&us.z_filefunc, us.filestream); |
| 619 | if (central_pos) |
| 620 | { |
| 621 | uLong uS; |
| 622 | ZPOS64_T uL64; |
| 623 | |
| 624 | us.isZip64 = 1; |
| 625 | |
| 626 | if (ZSEEK64(us.z_filefunc, us.filestream, |
| 627 | central_pos,ZLIB_FILEFUNC_SEEK_SET) != 0) |
| 628 | err = UNZ_ERRNO; |
| 629 | |
| 630 | /* the signature, already checked */ |
| 631 | if (unz64local_getLong(&us.z_filefunc, us.filestream, &uL) != UNZ_OK) |
| 632 | err = UNZ_ERRNO; |
| 633 | |
| 634 | /* size of zip64 end of central directory record */ |
| 635 | if (unz64local_getLong64(&us.z_filefunc, us.filestream, &uL64) != UNZ_OK) |
| 636 | err = UNZ_ERRNO; |
| 637 |
no test coverage detected