96 #ifndef CASESENSITIVITYDEFAULT_NO
97 # if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
98 # define CASESENSITIVITYDEFAULT_NO
104 #define UNZ_BUFSIZE (16384)
107 #ifndef UNZ_MAXFILENAMEINZIP
108 #define UNZ_MAXFILENAMEINZIP (256)
112 # define ALLOC(size) (malloc(size))
115 # define TRYFREE(p) {if (p) free(p);}
118 #define SIZECENTRALDIRITEM (0x2e)
119 #define SIZEZIPLOCALHEADER (0x1e)
122 const char unz_copyright[] =
123 " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
128 ZPOS64_T offset_curfile;
143 ZPOS64_T pos_in_zipfile;
144 uLong stream_initialised;
146 ZPOS64_T offset_local_extrafield;
147 uInt size_local_extrafield;
148 ZPOS64_T pos_local_extrafield;
149 ZPOS64_T total_out_64;
153 ZPOS64_T rest_read_compressed;
154 ZPOS64_T rest_read_uncompressed;
157 uLong compression_method;
158 ZPOS64_T byte_before_the_zipfile;
168 int is64bitOpenFunction;
171 ZPOS64_T byte_before_the_zipfile;
173 ZPOS64_T pos_in_central_dir;
174 ZPOS64_T current_file_ok;
175 ZPOS64_T central_pos;
177 ZPOS64_T size_central_dir;
178 ZPOS64_T offset_central_dir;
190 unsigned long keys[3];
191 const unsigned long* pcrc_32_tab;
207 local
int unz64local_getByte OF((
212 local
int unz64local_getByte(
const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream,
int *pi)
215 int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
223 if (ZERROR64(*pzlib_filefunc_def,filestream))
234 local
int unz64local_getShort OF((
247 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
251 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
261 local
int unz64local_getLong OF((
274 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
278 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
282 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
286 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
296 local
int unz64local_getLong64 OF((
310 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
314 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
315 x |= ((ZPOS64_T)i)<<8;
318 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
319 x |= ((ZPOS64_T)i)<<16;
322 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
323 x |= ((ZPOS64_T)i)<<24;
326 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
327 x |= ((ZPOS64_T)i)<<32;
330 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
331 x |= ((ZPOS64_T)i)<<40;
334 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
335 x |= ((ZPOS64_T)i)<<48;
338 err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);
339 x |= ((ZPOS64_T)i)<<56;
349 local
int strcmpcasenosensitive_internal (
const char* fileName1,
const char* fileName2)
353 char c1=*(fileName1++);
354 char c2=*(fileName2++);
355 if ((c1>=
'a') && (c1<=
'z'))
357 if ((c2>=
'a') && (c2<=
'z'))
360 return ((c2==
'\0') ? 0 : -1);
371 #ifdef CASESENSITIVITYDEFAULT_NO
372 #define CASESENSITIVITYDEFAULTVALUE 2
374 #define CASESENSITIVITYDEFAULTVALUE 1
377 #ifndef STRCMPCASENOSENTIVEFUNCTION
378 #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
390 extern int ZEXPORT unzStringFileNameCompare (
const char* fileName1,
391 const char* fileName2,
392 int iCaseSensitivity)
395 if (iCaseSensitivity==0)
396 iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
398 if (iCaseSensitivity==1)
399 return strcmp(fileName1,fileName2);
401 return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
404 #ifndef BUFREADCOMMENT
405 #define BUFREADCOMMENT (0x400)
412 local ZPOS64_T unz64local_SearchCentralDir OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
413 local ZPOS64_T unz64local_SearchCentralDir(
const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
418 ZPOS64_T uMaxBack=0xffff;
419 ZPOS64_T uPosFound=0;
421 if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
425 uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
427 if (uMaxBack>uSizeFile)
428 uMaxBack = uSizeFile;
430 buf = (
unsigned char*)ALLOC(BUFREADCOMMENT+4);
435 while (uBackRead<uMaxBack)
440 if (uBackRead+BUFREADCOMMENT>uMaxBack)
441 uBackRead = uMaxBack;
443 uBackRead+=BUFREADCOMMENT;
444 uReadPos = uSizeFile-uBackRead ;
446 uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
447 (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
448 if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
451 if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
454 for (i=(
int)uReadSize-3; (i--)>0;)
455 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
456 ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
458 uPosFound = uReadPos+i;
474 local ZPOS64_T unz64local_SearchCentralDir64 OF((
484 ZPOS64_T uMaxBack=0xffff;
485 ZPOS64_T uPosFound=0;
487 ZPOS64_T relativeOffset;
489 if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
493 uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
495 if (uMaxBack>uSizeFile)
496 uMaxBack = uSizeFile;
498 buf = (
unsigned char*)ALLOC(BUFREADCOMMENT+4);
503 while (uBackRead<uMaxBack)
508 if (uBackRead+BUFREADCOMMENT>uMaxBack)
509 uBackRead = uMaxBack;
511 uBackRead+=BUFREADCOMMENT;
512 uReadPos = uSizeFile-uBackRead ;
514 uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
515 (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
516 if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
519 if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
522 for (i=(
int)uReadSize-3; (i--)>0;)
523 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
524 ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
526 uPosFound = uReadPos+i;
538 if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)
542 if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
546 if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
552 if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK)
556 if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
562 if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
566 if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)
569 if (uL != 0x06064b50)
572 return relativeOffset;
584 local unzFile unzOpenInternal (
const void *path,
586 int is64bitOpenFunction)
590 ZPOS64_T central_pos;
595 uLong number_disk_with_CD;
597 ZPOS64_T number_entry_CD;
603 if (unz_copyright[0]!=
' ')
606 us.z_filefunc.zseek32_file = NULL;
607 us.z_filefunc.ztell32_file = NULL;
608 if (pzlib_filefunc64_32_def==NULL)
609 fill_fopen64_filefunc(&us.z_filefunc.zfile_func64);
611 us.z_filefunc = *pzlib_filefunc64_32_def;
612 us.is64bitOpenFunction = is64bitOpenFunction;
616 us.filestream = ZOPEN64(us.z_filefunc,
618 ZLIB_FILEFUNC_MODE_READ |
619 ZLIB_FILEFUNC_MODE_EXISTING);
620 if (us.filestream==NULL)
623 central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream);
631 if (ZSEEK64(us.z_filefunc, us.filestream,
632 central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
636 if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
640 if (unz64local_getLong64(&us.z_filefunc, us.filestream,&uL64)!=UNZ_OK)
644 if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
648 if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)
652 if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
656 if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
660 if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)
664 if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
667 if ((number_entry_CD!=us.gi.number_entry) ||
668 (number_disk_with_CD!=0) ||
673 if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)
678 if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)
681 us.gi.size_comment = 0;
685 central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream);
691 if (ZSEEK64(us.z_filefunc, us.filestream,
692 central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
696 if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
700 if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
704 if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
708 if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
710 us.gi.number_entry = uL;
713 if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
715 number_entry_CD = uL;
717 if ((number_entry_CD!=us.gi.number_entry) ||
718 (number_disk_with_CD!=0) ||
723 if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
725 us.size_central_dir = uL;
729 if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
731 us.offset_central_dir = uL;
734 if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)
738 if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
744 ZCLOSE64(us.z_filefunc, us.filestream);
748 us.byte_before_the_zipfile = central_pos -
749 (us.offset_central_dir+us.size_central_dir);
750 us.central_pos = central_pos;
751 us.pfile_in_zip_read = NULL;
759 unzGoToFirstFile((unzFile)s);
765 extern unzFile ZEXPORT unzOpen2 (
const char *path,
768 if (pzlib_filefunc32_def != NULL)
771 fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def);
772 return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0);
775 return unzOpenInternal(path, NULL, 0);
778 extern unzFile ZEXPORT unzOpen2_64 (
const void *path,
781 if (pzlib_filefunc_def != NULL)
784 zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
785 zlib_filefunc64_32_def_fill.ztell32_file = NULL;
786 zlib_filefunc64_32_def_fill.zseek32_file = NULL;
787 return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);
790 return unzOpenInternal(path, NULL, 1);
793 extern unzFile ZEXPORT unzOpen (
const char *path)
795 return unzOpenInternal(path, NULL, 0);
798 extern unzFile ZEXPORT unzOpen64 (
const void *path)
800 return unzOpenInternal(path, NULL, 1);
808 extern int ZEXPORT unzClose (unzFile file)
812 return UNZ_PARAMERROR;
815 if (s->pfile_in_zip_read!=NULL)
816 unzCloseCurrentFile(file);
818 ZCLOSE64(s->z_filefunc, s->filestream);
828 extern int ZEXPORT unzGetGlobalInfo64 (unzFile file,
unz_global_info64* pglobal_info)
832 return UNZ_PARAMERROR;
838 extern int ZEXPORT unzGetGlobalInfo (unzFile file,
unz_global_info* pglobal_info32)
842 return UNZ_PARAMERROR;
845 pglobal_info32->number_entry = (uLong)s->gi.number_entry;
846 pglobal_info32->size_comment = s->gi.size_comment;
852 local
void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate,
tm_unz* ptm)
855 uDate = (ZPOS64_T)(ulDosDate>>16);
856 ptm->tm_mday = (uInt)(uDate&0x1f) ;
857 ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
858 ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
860 ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
861 ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
862 ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
868 local
int unz64local_GetCurrentFileInfoInternal OF((unzFile file,
871 *pfile_info_internal,
873 uLong fileNameBufferSize,
875 uLong extraFieldBufferSize,
877 uLong commentBufferSize));
879 local
int unz64local_GetCurrentFileInfoInternal (unzFile file,
882 *pfile_info_internal,
884 uLong fileNameBufferSize,
886 uLong extraFieldBufferSize,
888 uLong commentBufferSize)
899 return UNZ_PARAMERROR;
901 if (ZSEEK64(s->z_filefunc, s->filestream,
902 s->pos_in_central_dir+s->byte_before_the_zipfile,
903 ZLIB_FILEFUNC_SEEK_SET)!=0)
910 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
912 else if (uMagic!=0x02014b50)
916 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
919 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)
922 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
925 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)
928 if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
931 unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
933 if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
936 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
938 file_info.compressed_size = uL;
940 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
942 file_info.uncompressed_size = uL;
944 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)
947 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)
950 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)
953 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
956 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
959 if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
963 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
965 file_info_internal.offset_curfile = uL;
967 lSeek+=file_info.size_filename;
968 if ((err==UNZ_OK) && (szFileName!=NULL))
971 if (file_info.size_filename<fileNameBufferSize)
973 *(szFileName+file_info.size_filename)=
'\0';
974 uSizeRead = file_info.size_filename;
977 uSizeRead = fileNameBufferSize;
979 if ((file_info.size_filename>0) && (fileNameBufferSize>0))
980 if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
986 if ((err==UNZ_OK) && (extraField!=NULL))
989 if (file_info.size_file_extra<extraFieldBufferSize)
990 uSizeRead = file_info.size_file_extra;
992 uSizeRead = extraFieldBufferSize;
996 if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
1002 if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
1003 if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead)
1006 lSeek += file_info.size_file_extra - (uLong)uSizeRead;
1009 lSeek += file_info.size_file_extra;
1012 if ((err==UNZ_OK) && (file_info.size_file_extra != 0))
1017 lSeek -= file_info.size_file_extra;
1021 if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
1027 while(acc < file_info.size_file_extra)
1032 if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK)
1035 if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK)
1039 if (headerId == 0x0001)
1043 if(file_info.uncompressed_size == (ZPOS64_T)(
unsigned long)-1)
1045 if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
1049 if(file_info.compressed_size == (ZPOS64_T)(
unsigned long)-1)
1051 if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
1055 if(file_info_internal.offset_curfile == (ZPOS64_T)(
unsigned long)-1)
1058 if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
1062 if(file_info.disk_num_start == (
unsigned long)-1)
1065 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
1072 if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0)
1076 acc += 2 + 2 + dataSize;
1080 if ((err==UNZ_OK) && (szComment!=NULL))
1083 if (file_info.size_file_comment<commentBufferSize)
1085 *(szComment+file_info.size_file_comment)=
'\0';
1086 uSizeRead = file_info.size_file_comment;
1089 uSizeRead = commentBufferSize;
1093 if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
1099 if ((file_info.size_file_comment>0) && (commentBufferSize>0))
1100 if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
1102 lSeek+=file_info.size_file_comment - uSizeRead;
1105 lSeek+=file_info.size_file_comment;
1108 if ((err==UNZ_OK) && (pfile_info!=NULL))
1109 *pfile_info=file_info;
1111 if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
1112 *pfile_info_internal=file_info_internal;
1124 extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file,
1126 char * szFileName, uLong fileNameBufferSize,
1127 void *extraField, uLong extraFieldBufferSize,
1128 char* szComment, uLong commentBufferSize)
1130 return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL,
1131 szFileName,fileNameBufferSize,
1132 extraField,extraFieldBufferSize,
1133 szComment,commentBufferSize);
1136 extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
1138 char * szFileName, uLong fileNameBufferSize,
1139 void *extraField, uLong extraFieldBufferSize,
1140 char* szComment, uLong commentBufferSize)
1144 err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL,
1145 szFileName,fileNameBufferSize,
1146 extraField,extraFieldBufferSize,
1147 szComment,commentBufferSize);
1150 pfile_info->version = file_info64.version;
1151 pfile_info->version_needed = file_info64.version_needed;
1152 pfile_info->flag = file_info64.flag;
1153 pfile_info->compression_method = file_info64.compression_method;
1154 pfile_info->dosDate = file_info64.dosDate;
1155 pfile_info->crc = file_info64.crc;
1157 pfile_info->size_filename = file_info64.size_filename;
1158 pfile_info->size_file_extra = file_info64.size_file_extra;
1159 pfile_info->size_file_comment = file_info64.size_file_comment;
1161 pfile_info->disk_num_start = file_info64.disk_num_start;
1162 pfile_info->internal_fa = file_info64.internal_fa;
1163 pfile_info->external_fa = file_info64.external_fa;
1165 pfile_info->tmu_date = file_info64.tmu_date,
1168 pfile_info->compressed_size = (uLong)file_info64.compressed_size;
1169 pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;
1178 extern int ZEXPORT unzGoToFirstFile (unzFile file)
1183 return UNZ_PARAMERROR;
1185 s->pos_in_central_dir=s->offset_central_dir;
1187 err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1188 &s->cur_file_info_internal,
1189 NULL,0,NULL,0,NULL,0);
1190 s->current_file_ok = (err == UNZ_OK);
1199 extern int ZEXPORT unzGoToNextFile (unzFile file)
1205 return UNZ_PARAMERROR;
1207 if (!s->current_file_ok)
1208 return UNZ_END_OF_LIST_OF_FILE;
1209 if (s->gi.number_entry != 0xffff)
1210 if (s->num_file+1==s->gi.number_entry)
1211 return UNZ_END_OF_LIST_OF_FILE;
1213 s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
1214 s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
1216 err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1217 &s->cur_file_info_internal,
1218 NULL,0,NULL,0,NULL,0);
1219 s->current_file_ok = (err == UNZ_OK);
1232 extern int ZEXPORT unzLocateFile (unzFile file,
const char *szFileName,
int iCaseSensitivity)
1242 ZPOS64_T num_fileSaved;
1243 ZPOS64_T pos_in_central_dirSaved;
1247 return UNZ_PARAMERROR;
1249 if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
1250 return UNZ_PARAMERROR;
1253 if (!s->current_file_ok)
1254 return UNZ_END_OF_LIST_OF_FILE;
1257 num_fileSaved = s->num_file;
1258 pos_in_central_dirSaved = s->pos_in_central_dir;
1259 cur_file_infoSaved = s->cur_file_info;
1260 cur_file_info_internalSaved = s->cur_file_info_internal;
1262 err = unzGoToFirstFile(file);
1264 while (err == UNZ_OK)
1266 char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
1267 err = unzGetCurrentFileInfo64(file,NULL,
1268 szCurrentFileName,
sizeof(szCurrentFileName)-1,
1272 if (unzStringFileNameCompare(szCurrentFileName,
1273 szFileName,iCaseSensitivity)==0)
1275 err = unzGoToNextFile(file);
1282 s->num_file = num_fileSaved ;
1283 s->pos_in_central_dir = pos_in_central_dirSaved ;
1284 s->cur_file_info = cur_file_infoSaved;
1285 s->cur_file_info_internal = cur_file_info_internalSaved;
1308 extern int ZEXPORT unzGetFilePos64(unzFile file,
unz64_file_pos* file_pos)
1312 if (file==NULL || file_pos==NULL)
1313 return UNZ_PARAMERROR;
1315 if (!s->current_file_ok)
1316 return UNZ_END_OF_LIST_OF_FILE;
1318 file_pos->pos_in_zip_directory = s->pos_in_central_dir;
1319 file_pos->num_of_file = s->num_file;
1324 extern int ZEXPORT unzGetFilePos(
1329 int err = unzGetFilePos64(file,&file_pos64);
1332 file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory;
1333 file_pos->num_of_file = (uLong)file_pos64.num_of_file;
1338 extern int ZEXPORT unzGoToFilePos64(unzFile file,
const unz64_file_pos* file_pos)
1343 if (file==NULL || file_pos==NULL)
1344 return UNZ_PARAMERROR;
1348 s->pos_in_central_dir = file_pos->pos_in_zip_directory;
1349 s->num_file = file_pos->num_of_file;
1352 err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1353 &s->cur_file_info_internal,
1354 NULL,0,NULL,0,NULL,0);
1356 s->current_file_ok = (err == UNZ_OK);
1360 extern int ZEXPORT unzGoToFilePos(
1365 if (file_pos == NULL)
1366 return UNZ_PARAMERROR;
1368 file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory;
1369 file_pos64.num_of_file = file_pos->num_of_file;
1370 return unzGoToFilePos64(file,&file_pos64);
1385 local
int unz64local_CheckCurrentFileCoherencyHeader (
unz64_s* s, uInt* piSizeVar,
1386 ZPOS64_T * poffset_local_extrafield,
1387 uInt * psize_local_extrafield)
1389 uLong uMagic,uData,uFlags;
1390 uLong size_filename;
1391 uLong size_extra_field;
1395 *poffset_local_extrafield = 0;
1396 *psize_local_extrafield = 0;
1398 if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
1399 s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
1405 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
1407 else if (uMagic!=0x04034b50)
1411 if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
1417 if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
1420 if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
1422 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
1425 if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
1427 (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
1429 (s->cur_file_info.compression_method!=Z_DEFLATED))
1432 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
1435 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
1437 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0))
1440 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
1442 else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0))
1445 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
1447 else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0))
1450 if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
1452 else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
1455 *piSizeVar += (uInt)size_filename;
1457 if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
1459 *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
1460 SIZEZIPLOCALHEADER + size_filename;
1461 *psize_local_extrafield = (uInt)size_extra_field;
1463 *piSizeVar += (uInt)size_extra_field;
1472 extern int ZEXPORT unzOpenCurrentFile3 (unzFile file,
int* method,
1473 int* level,
int raw,
const char* password)
1479 ZPOS64_T offset_local_extrafield;
1480 uInt size_local_extrafield;
1484 if (password != NULL)
1485 return UNZ_PARAMERROR;
1489 return UNZ_PARAMERROR;
1491 if (!s->current_file_ok)
1492 return UNZ_PARAMERROR;
1494 if (s->pfile_in_zip_read != NULL)
1495 unzCloseCurrentFile(file);
1497 if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
1498 return UNZ_BADZIPFILE;
1501 if (pfile_in_zip_read_info==NULL)
1502 return UNZ_INTERNALERROR;
1504 pfile_in_zip_read_info->read_buffer=(
char*)ALLOC(UNZ_BUFSIZE);
1505 pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
1506 pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
1507 pfile_in_zip_read_info->pos_local_extrafield=0;
1508 pfile_in_zip_read_info->raw=raw;
1510 if (pfile_in_zip_read_info->read_buffer==NULL)
1512 TRYFREE(pfile_in_zip_read_info);
1513 return UNZ_INTERNALERROR;
1516 pfile_in_zip_read_info->stream_initialised=0;
1519 *method = (int)s->cur_file_info.compression_method;
1524 switch (s->cur_file_info.flag & 0x06)
1526 case 6 : *level = 1;
break;
1527 case 4 : *level = 2;
break;
1528 case 2 : *level = 9;
break;
1532 if ((s->cur_file_info.compression_method!=0) &&
1534 (s->cur_file_info.compression_method!=Z_BZIP2ED) &&
1536 (s->cur_file_info.compression_method!=Z_DEFLATED))
1540 pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
1541 pfile_in_zip_read_info->crc32=0;
1542 pfile_in_zip_read_info->total_out_64=0;
1543 pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method;
1544 pfile_in_zip_read_info->filestream=s->filestream;
1545 pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
1546 pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
1548 pfile_in_zip_read_info->stream.total_out = 0;
1550 if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw))
1553 pfile_in_zip_read_info->bstream.bzalloc = (
void *(*) (
void *, int, int))0;
1554 pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
1555 pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
1556 pfile_in_zip_read_info->bstream.state = (voidpf)0;
1558 pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
1559 pfile_in_zip_read_info->stream.zfree = (free_func)0;
1560 pfile_in_zip_read_info->stream.opaque = (voidpf)0;
1561 pfile_in_zip_read_info->stream.next_in = (voidpf)0;
1562 pfile_in_zip_read_info->stream.avail_in = 0;
1564 err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
1566 pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
1569 TRYFREE(pfile_in_zip_read_info);
1573 pfile_in_zip_read_info->raw=1;
1576 else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))
1578 pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
1579 pfile_in_zip_read_info->stream.zfree = (free_func)0;
1580 pfile_in_zip_read_info->stream.opaque = (voidpf)0;
1581 pfile_in_zip_read_info->stream.next_in = 0;
1582 pfile_in_zip_read_info->stream.avail_in = 0;
1584 err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
1586 pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
1589 TRYFREE(pfile_in_zip_read_info);
1600 pfile_in_zip_read_info->rest_read_compressed =
1601 s->cur_file_info.compressed_size ;
1602 pfile_in_zip_read_info->rest_read_uncompressed =
1603 s->cur_file_info.uncompressed_size ;
1606 pfile_in_zip_read_info->pos_in_zipfile =
1607 s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
1610 pfile_in_zip_read_info->stream.avail_in = (uInt)0;
1612 s->pfile_in_zip_read = pfile_in_zip_read_info;
1616 if (password != NULL)
1619 s->pcrc_32_tab = get_crc_table();
1620 init_keys(password,s->keys,s->pcrc_32_tab);
1621 if (ZSEEK64(s->z_filefunc, s->filestream,
1622 s->pfile_in_zip_read->pos_in_zipfile +
1623 s->pfile_in_zip_read->byte_before_the_zipfile,
1625 return UNZ_INTERNALERROR;
1626 if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12)
1627 return UNZ_INTERNALERROR;
1629 for (i = 0; i<12; i++)
1630 zdecode(s->keys,s->pcrc_32_tab,source[i]);
1632 s->pfile_in_zip_read->pos_in_zipfile+=12;
1641 extern int ZEXPORT unzOpenCurrentFile (unzFile file)
1643 return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
1646 extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file,
const char* password)
1648 return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
1651 extern int ZEXPORT unzOpenCurrentFile2 (unzFile file,
int* method,
int* level,
int raw)
1653 return unzOpenCurrentFile3(file, method, level, raw, NULL);
1658 extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file)
1665 pfile_in_zip_read_info=s->pfile_in_zip_read;
1666 if (pfile_in_zip_read_info==NULL)
1668 return pfile_in_zip_read_info->pos_in_zipfile +
1669 pfile_in_zip_read_info->byte_before_the_zipfile;
1684 extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf,
unsigned len)
1691 return UNZ_PARAMERROR;
1693 pfile_in_zip_read_info=s->pfile_in_zip_read;
1695 if (pfile_in_zip_read_info==NULL)
1696 return UNZ_PARAMERROR;
1699 if ((pfile_in_zip_read_info->read_buffer == NULL))
1700 return UNZ_END_OF_LIST_OF_FILE;
1704 pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
1706 pfile_in_zip_read_info->stream.avail_out = (uInt)len;
1708 if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
1709 (!(pfile_in_zip_read_info->raw)))
1710 pfile_in_zip_read_info->stream.avail_out =
1711 (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
1713 if ((len>pfile_in_zip_read_info->rest_read_compressed+
1714 pfile_in_zip_read_info->stream.avail_in) &&
1715 (pfile_in_zip_read_info->raw))
1716 pfile_in_zip_read_info->stream.avail_out =
1717 (uInt)pfile_in_zip_read_info->rest_read_compressed+
1718 pfile_in_zip_read_info->stream.avail_in;
1720 while (pfile_in_zip_read_info->stream.avail_out>0)
1722 if ((pfile_in_zip_read_info->stream.avail_in==0) &&
1723 (pfile_in_zip_read_info->rest_read_compressed>0))
1725 uInt uReadThis = UNZ_BUFSIZE;
1726 if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
1727 uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
1730 if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
1731 pfile_in_zip_read_info->filestream,
1732 pfile_in_zip_read_info->pos_in_zipfile +
1733 pfile_in_zip_read_info->byte_before_the_zipfile,
1734 ZLIB_FILEFUNC_SEEK_SET)!=0)
1736 if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
1737 pfile_in_zip_read_info->filestream,
1738 pfile_in_zip_read_info->read_buffer,
1739 uReadThis)!=uReadThis)
1747 for(i=0;i<uReadThis;i++)
1748 pfile_in_zip_read_info->read_buffer[i] =
1749 zdecode(s->keys,s->pcrc_32_tab,
1750 pfile_in_zip_read_info->read_buffer[i]);
1755 pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
1757 pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
1759 pfile_in_zip_read_info->stream.next_in =
1760 (Bytef*)pfile_in_zip_read_info->read_buffer;
1761 pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
1764 if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
1768 if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
1769 (pfile_in_zip_read_info->rest_read_compressed == 0))
1770 return (iRead==0) ? UNZ_EOF : iRead;
1772 if (pfile_in_zip_read_info->stream.avail_out <
1773 pfile_in_zip_read_info->stream.avail_in)
1774 uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
1776 uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
1778 for (i=0;i<uDoCopy;i++)
1779 *(pfile_in_zip_read_info->stream.next_out+i) =
1780 *(pfile_in_zip_read_info->stream.next_in+i);
1782 pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy;
1784 pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
1785 pfile_in_zip_read_info->stream.next_out,
1787 pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
1788 pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
1789 pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
1790 pfile_in_zip_read_info->stream.next_out += uDoCopy;
1791 pfile_in_zip_read_info->stream.next_in += uDoCopy;
1792 pfile_in_zip_read_info->stream.total_out += uDoCopy;
1795 else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED)
1798 uLong uTotalOutBefore,uTotalOutAfter;
1799 const Bytef *bufBefore;
1802 pfile_in_zip_read_info->bstream.next_in = (
char*)pfile_in_zip_read_info->stream.next_in;
1803 pfile_in_zip_read_info->bstream.avail_in = pfile_in_zip_read_info->stream.avail_in;
1804 pfile_in_zip_read_info->bstream.total_in_lo32 = pfile_in_zip_read_info->stream.total_in;
1805 pfile_in_zip_read_info->bstream.total_in_hi32 = 0;
1806 pfile_in_zip_read_info->bstream.next_out = (
char*)pfile_in_zip_read_info->stream.next_out;
1807 pfile_in_zip_read_info->bstream.avail_out = pfile_in_zip_read_info->stream.avail_out;
1808 pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out;
1809 pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
1811 uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;
1812 bufBefore = (
const Bytef *)pfile_in_zip_read_info->bstream.next_out;
1814 err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
1816 uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;
1817 uOutThis = uTotalOutAfter-uTotalOutBefore;
1819 pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
1821 pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis));
1822 pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis;
1823 iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
1825 pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->bstream.next_in;
1826 pfile_in_zip_read_info->stream.avail_in = pfile_in_zip_read_info->bstream.avail_in;
1827 pfile_in_zip_read_info->stream.total_in = pfile_in_zip_read_info->bstream.total_in_lo32;
1828 pfile_in_zip_read_info->stream.next_out = (Bytef*)pfile_in_zip_read_info->bstream.next_out;
1829 pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;
1830 pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
1832 if (err==BZ_STREAM_END)
1833 return (iRead==0) ? UNZ_EOF : iRead;
1840 ZPOS64_T uTotalOutBefore,uTotalOutAfter;
1841 const Bytef *bufBefore;
1843 int flush=Z_SYNC_FLUSH;
1845 uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
1846 bufBefore = pfile_in_zip_read_info->stream.next_out;
1854 err=inflate(&pfile_in_zip_read_info->stream,flush);
1856 if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
1859 uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
1860 uOutThis = uTotalOutAfter-uTotalOutBefore;
1862 pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;
1864 pfile_in_zip_read_info->crc32 =
1865 crc32(pfile_in_zip_read_info->crc32,bufBefore,
1868 pfile_in_zip_read_info->rest_read_uncompressed -=
1871 iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
1873 if (err==Z_STREAM_END)
1874 return (iRead==0) ? UNZ_EOF : iRead;
1889 extern z_off_t ZEXPORT unztell (unzFile file)
1894 return UNZ_PARAMERROR;
1896 pfile_in_zip_read_info=s->pfile_in_zip_read;
1898 if (pfile_in_zip_read_info==NULL)
1899 return UNZ_PARAMERROR;
1901 return (z_off_t)pfile_in_zip_read_info->stream.total_out;
1904 extern ZPOS64_T ZEXPORT unztell64 (unzFile file)
1910 return (ZPOS64_T)-1;
1912 pfile_in_zip_read_info=s->pfile_in_zip_read;
1914 if (pfile_in_zip_read_info==NULL)
1915 return (ZPOS64_T)-1;
1917 return pfile_in_zip_read_info->total_out_64;
1924 extern int ZEXPORT unzeof (unzFile file)
1929 return UNZ_PARAMERROR;
1931 pfile_in_zip_read_info=s->pfile_in_zip_read;
1933 if (pfile_in_zip_read_info==NULL)
1934 return UNZ_PARAMERROR;
1936 if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
1956 extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf,
unsigned len)
1961 ZPOS64_T size_to_read;
1964 return UNZ_PARAMERROR;
1966 pfile_in_zip_read_info=s->pfile_in_zip_read;
1968 if (pfile_in_zip_read_info==NULL)
1969 return UNZ_PARAMERROR;
1971 size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
1972 pfile_in_zip_read_info->pos_local_extrafield);
1975 return (
int)size_to_read;
1977 if (len>size_to_read)
1978 read_now = (uInt)size_to_read;
1980 read_now = (uInt)len ;
1985 if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
1986 pfile_in_zip_read_info->filestream,
1987 pfile_in_zip_read_info->offset_local_extrafield +
1988 pfile_in_zip_read_info->pos_local_extrafield,
1989 ZLIB_FILEFUNC_SEEK_SET)!=0)
1992 if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
1993 pfile_in_zip_read_info->filestream,
1994 buf,read_now)!=read_now)
1997 return (
int)read_now;
2004 extern int ZEXPORT unzCloseCurrentFile (unzFile file)
2011 return UNZ_PARAMERROR;
2013 pfile_in_zip_read_info=s->pfile_in_zip_read;
2015 if (pfile_in_zip_read_info==NULL)
2016 return UNZ_PARAMERROR;
2019 if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
2020 (!pfile_in_zip_read_info->raw))
2022 if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
2027 TRYFREE(pfile_in_zip_read_info->read_buffer);
2028 pfile_in_zip_read_info->read_buffer = NULL;
2029 if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
2030 inflateEnd(&pfile_in_zip_read_info->stream);
2032 else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED)
2033 BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
2037 pfile_in_zip_read_info->stream_initialised = 0;
2038 TRYFREE(pfile_in_zip_read_info);
2040 s->pfile_in_zip_read=NULL;
2051 extern int ZEXPORT unzGetGlobalComment (unzFile file,
char * szComment, uLong uSizeBuf)
2056 return (
int)UNZ_PARAMERROR;
2059 uReadThis = uSizeBuf;
2060 if (uReadThis>s->gi.size_comment)
2061 uReadThis = s->gi.size_comment;
2063 if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
2069 if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
2073 if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
2074 *(szComment+s->gi.size_comment)=
'\0';
2075 return (
int)uReadThis;
2079 extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)
2086 if (!s->current_file_ok)
2088 if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
2089 if (s->num_file==s->gi.number_entry)
2091 return s->pos_in_central_dir;
2094 extern uLong ZEXPORT unzGetOffset (unzFile file)
2100 offset64 = unzGetOffset64(file);
2101 return (uLong)offset64;
2104 extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)
2110 return UNZ_PARAMERROR;
2113 s->pos_in_central_dir = pos;
2114 s->num_file = s->gi.number_entry;
2115 err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
2116 &s->cur_file_info_internal,
2117 NULL,0,NULL,0,NULL,0);
2118 s->current_file_ok = (err == UNZ_OK);
2122 extern int ZEXPORT unzSetOffset (unzFile file, uLong pos)
2124 return unzSetOffset64(file,pos);