Chromium Code Reviews

Side by Side Diff: third_party/zlib/contrib/minizip/unzip.c

Issue 1955383002: Update Zlib to version 1.2.8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update zlib to version 1.2.8 Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 /* unzip.c -- IO for uncompress .zip files using zlib 1 /* unzip.c -- IO for uncompress .zip files using zlib
2 Version 1.1, February 14h, 2010 2 Version 1.1, February 14h, 2010
3 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) 3 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
4 4
5 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage. com/zLibDll/minizip.html ) 5 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage. com/zLibDll/minizip.html )
6 6
7 Modifications of Unzip for Zip64 7 Modifications of Unzip for Zip64
8 Copyright (C) 2007-2008 Even Rouault 8 Copyright (C) 2007-2008 Even Rouault
9 9
10 Modifications for Zip64 support on both zip and unzip 10 Modifications for Zip64 support on both zip and unzip
(...skipping 170 matching lines...)
181 unz_file_info64 cur_file_info; /* public info about the current file in zip* / 181 unz_file_info64 cur_file_info; /* public info about the current file in zip* /
182 unz_file_info64_internal cur_file_info_internal; /* private info about it*/ 182 unz_file_info64_internal cur_file_info_internal; /* private info about it*/
183 file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current 183 file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current
184 file if we are decompressing it */ 184 file if we are decompressing it */
185 int encrypted; 185 int encrypted;
186 186
187 int isZip64; 187 int isZip64;
188 188
189 # ifndef NOUNCRYPT 189 # ifndef NOUNCRYPT
190 unsigned long keys[3]; /* keys defining the pseudo-random sequence */ 190 unsigned long keys[3]; /* keys defining the pseudo-random sequence */
191 const unsigned long* pcrc_32_tab; 191 const z_crc_t* pcrc_32_tab;
192 # endif 192 # endif
193 } unz64_s; 193 } unz64_s;
194 194
195 195
196 #ifndef NOUNCRYPT 196 #ifndef NOUNCRYPT
197 #include "crypt.h" 197 #include "crypt.h"
198 #endif 198 #endif
199 199
200 /* =========================================================================== 200 /* ===========================================================================
201 Read a byte from a gz_stream; update next_in and avail_in. Return EOF 201 Read a byte from a gz_stream; update next_in and avail_in. Return EOF
(...skipping 592 matching lines...)
794 { 794 {
795 return unzOpenInternal(path, NULL, 0); 795 return unzOpenInternal(path, NULL, 0);
796 } 796 }
797 797
798 extern unzFile ZEXPORT unzOpen64 (const void *path) 798 extern unzFile ZEXPORT unzOpen64 (const void *path)
799 { 799 {
800 return unzOpenInternal(path, NULL, 1); 800 return unzOpenInternal(path, NULL, 1);
801 } 801 }
802 802
803 /* 803 /*
804 Close a ZipFile opened with unzipOpen. 804 Close a ZipFile opened with unzOpen.
805 If there is files inside the .Zip opened with unzipOpenCurrentFile (see later) , 805 If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
806 these files MUST be closed with unzipCloseCurrentFile before call unzipClose . 806 these files MUST be closed with unzCloseCurrentFile before call unzClose.
807 return UNZ_OK if there is no problem. */ 807 return UNZ_OK if there is no problem. */
808 extern int ZEXPORT unzClose (unzFile file) 808 extern int ZEXPORT unzClose (unzFile file)
809 { 809 {
810 unz64_s* s; 810 unz64_s* s;
811 if (file==NULL) 811 if (file==NULL)
812 return UNZ_PARAMERROR; 812 return UNZ_PARAMERROR;
813 s=(unz64_s*)file; 813 s=(unz64_s*)file;
814 814
815 if (s->pfile_in_zip_read!=NULL) 815 if (s->pfile_in_zip_read!=NULL)
816 unzCloseCurrentFile(file); 816 unzCloseCurrentFile(file);
(...skipping 321 matching lines...)
1138 char * szFileName, uLong fileNameBuffe rSize, 1138 char * szFileName, uLong fileNameBuffe rSize,
1139 void *extraField, uLong extraFieldBuff erSize, 1139 void *extraField, uLong extraFieldBuff erSize,
1140 char* szComment, uLong commentBufferS ize) 1140 char* szComment, uLong commentBufferS ize)
1141 { 1141 {
1142 int err; 1142 int err;
1143 unz_file_info64 file_info64; 1143 unz_file_info64 file_info64;
1144 err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL, 1144 err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL,
1145 szFileName,fileNameBufferSize, 1145 szFileName,fileNameBufferSize,
1146 extraField,extraFieldBufferSize, 1146 extraField,extraFieldBufferSize,
1147 szComment,commentBufferSize); 1147 szComment,commentBufferSize);
1148 if (err==UNZ_OK) 1148 if ((err==UNZ_OK) && (pfile_info != NULL))
1149 { 1149 {
1150 pfile_info->version = file_info64.version; 1150 pfile_info->version = file_info64.version;
1151 pfile_info->version_needed = file_info64.version_needed; 1151 pfile_info->version_needed = file_info64.version_needed;
1152 pfile_info->flag = file_info64.flag; 1152 pfile_info->flag = file_info64.flag;
1153 pfile_info->compression_method = file_info64.compression_method; 1153 pfile_info->compression_method = file_info64.compression_method;
1154 pfile_info->dosDate = file_info64.dosDate; 1154 pfile_info->dosDate = file_info64.dosDate;
1155 pfile_info->crc = file_info64.crc; 1155 pfile_info->crc = file_info64.crc;
1156 1156
1157 pfile_info->size_filename = file_info64.size_filename; 1157 pfile_info->size_filename = file_info64.size_filename;
1158 pfile_info->size_file_extra = file_info64.size_file_extra; 1158 pfile_info->size_file_extra = file_info64.size_file_extra;
(...skipping 57 matching lines...)
1216 err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, 1216 err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1217 &s->cur_file_info_internal, 1217 &s->cur_file_info_internal,
1218 NULL,0,NULL,0,NULL,0); 1218 NULL,0,NULL,0,NULL,0);
1219 s->current_file_ok = (err == UNZ_OK); 1219 s->current_file_ok = (err == UNZ_OK);
1220 return err; 1220 return err;
1221 } 1221 }
1222 1222
1223 1223
1224 /* 1224 /*
1225 Try locate the file szFileName in the zipfile. 1225 Try locate the file szFileName in the zipfile.
1226 For the iCaseSensitivity signification, see unzipStringFileNameCompare 1226 For the iCaseSensitivity signification, see unzStringFileNameCompare
1227 1227
1228 return value : 1228 return value :
1229 UNZ_OK if the file is found. It becomes the current file. 1229 UNZ_OK if the file is found. It becomes the current file.
1230 UNZ_END_OF_LIST_OF_FILE if the file is not found 1230 UNZ_END_OF_LIST_OF_FILE if the file is not found
1231 */ 1231 */
1232 extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCas eSensitivity) 1232 extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCas eSensitivity)
1233 { 1233 {
1234 unz64_s* s; 1234 unz64_s* s;
1235 int err; 1235 int err;
1236 1236
(...skipping 452 matching lines...)
1689 file_in_zip64_read_info_s* pfile_in_zip_read_info; 1689 file_in_zip64_read_info_s* pfile_in_zip_read_info;
1690 if (file==NULL) 1690 if (file==NULL)
1691 return UNZ_PARAMERROR; 1691 return UNZ_PARAMERROR;
1692 s=(unz64_s*)file; 1692 s=(unz64_s*)file;
1693 pfile_in_zip_read_info=s->pfile_in_zip_read; 1693 pfile_in_zip_read_info=s->pfile_in_zip_read;
1694 1694
1695 if (pfile_in_zip_read_info==NULL) 1695 if (pfile_in_zip_read_info==NULL)
1696 return UNZ_PARAMERROR; 1696 return UNZ_PARAMERROR;
1697 1697
1698 1698
1699 if ((pfile_in_zip_read_info->read_buffer == NULL)) 1699 if (pfile_in_zip_read_info->read_buffer == NULL)
1700 return UNZ_END_OF_LIST_OF_FILE; 1700 return UNZ_END_OF_LIST_OF_FILE;
1701 if (len==0) 1701 if (len==0)
1702 return 0; 1702 return 0;
1703 1703
1704 pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; 1704 pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
1705 1705
1706 pfile_in_zip_read_info->stream.avail_out = (uInt)len; 1706 pfile_in_zip_read_info->stream.avail_out = (uInt)len;
1707 1707
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;
1712
1708 if ((len>pfile_in_zip_read_info->rest_read_compressed+ 1713 if ((len>pfile_in_zip_read_info->rest_read_compressed+
1709 pfile_in_zip_read_info->stream.avail_in) && 1714 pfile_in_zip_read_info->stream.avail_in) &&
1710 (pfile_in_zip_read_info->raw)) 1715 (pfile_in_zip_read_info->raw))
1711 pfile_in_zip_read_info->stream.avail_out = 1716 pfile_in_zip_read_info->stream.avail_out =
1712 (uInt)pfile_in_zip_read_info->rest_read_compressed+ 1717 (uInt)pfile_in_zip_read_info->rest_read_compressed+
1713 pfile_in_zip_read_info->stream.avail_in; 1718 pfile_in_zip_read_info->stream.avail_in;
1714 1719
1715 while (pfile_in_zip_read_info->stream.avail_out>0) 1720 while (pfile_in_zip_read_info->stream.avail_out>0)
1716 { 1721 {
1717 if ((pfile_in_zip_read_info->stream.avail_in==0) && 1722 if ((pfile_in_zip_read_info->stream.avail_in==0) &&
(...skipping 268 matching lines...)
1986 1991
1987 if (ZREAD64(pfile_in_zip_read_info->z_filefunc, 1992 if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
1988 pfile_in_zip_read_info->filestream, 1993 pfile_in_zip_read_info->filestream,
1989 buf,read_now)!=read_now) 1994 buf,read_now)!=read_now)
1990 return UNZ_ERRNO; 1995 return UNZ_ERRNO;
1991 1996
1992 return (int)read_now; 1997 return (int)read_now;
1993 } 1998 }
1994 1999
1995 /* 2000 /*
1996 Close the file in zip opened with unzipOpenCurrentFile 2001 Close the file in zip opened with unzOpenCurrentFile
1997 Return UNZ_CRCERROR if all the file was read but the CRC is not good 2002 Return UNZ_CRCERROR if all the file was read but the CRC is not good
1998 */ 2003 */
1999 extern int ZEXPORT unzCloseCurrentFile (unzFile file) 2004 extern int ZEXPORT unzCloseCurrentFile (unzFile file)
2000 { 2005 {
2001 int err=UNZ_OK; 2006 int err=UNZ_OK;
2002 2007
2003 unz64_s* s; 2008 unz64_s* s;
2004 file_in_zip64_read_info_s* pfile_in_zip_read_info; 2009 file_in_zip64_read_info_s* pfile_in_zip_read_info;
2005 if (file==NULL) 2010 if (file==NULL)
2006 return UNZ_PARAMERROR; 2011 return UNZ_PARAMERROR;
(...skipping 104 matching lines...)
2111 &s->cur_file_info_internal, 2116 &s->cur_file_info_internal,
2112 NULL,0,NULL,0,NULL,0); 2117 NULL,0,NULL,0,NULL,0);
2113 s->current_file_ok = (err == UNZ_OK); 2118 s->current_file_ok = (err == UNZ_OK);
2114 return err; 2119 return err;
2115 } 2120 }
2116 2121
2117 extern int ZEXPORT unzSetOffset (unzFile file, uLong pos) 2122 extern int ZEXPORT unzSetOffset (unzFile file, uLong pos)
2118 { 2123 {
2119 return unzSetOffset64(file,pos); 2124 return unzSetOffset64(file,pos);
2120 } 2125 }
OLDNEW

Powered by Google App Engine