diff options
Diffstat (limited to 'contrib/minizip/unzip.c')
-rw-r--r-- | contrib/minizip/unzip.c | 61 |
1 files changed, 54 insertions, 7 deletions
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c index f08f624..e804a2a 100644 --- a/contrib/minizip/unzip.c +++ b/contrib/minizip/unzip.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* unzip.c -- IO for uncompress .zip files using zlib | 1 | /* unzip.c -- IO for uncompress .zip files using zlib |
2 | Version 1.00, September 10th, 2003 | 2 | Version 1.01c, August 23th, 2004 |
3 | 3 | ||
4 | Copyright (C) 1998-2003 Gilles Vollant | 4 | Copyright (C) 1998-2004 Gilles Vollant |
5 | 5 | ||
6 | Read unzip.h for more info | 6 | Read unzip.h for more info |
7 | */ | 7 | */ |
@@ -88,7 +88,7 @@ woven in by Terry Thorsen 1/2003. | |||
88 | 88 | ||
89 | 89 | ||
90 | const char unz_copyright[] = | 90 | const char unz_copyright[] = |
91 | " unzip 1.00 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; | 91 | " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; |
92 | 92 | ||
93 | /* unz_file_info_interntal contain internal info about a file in zipfile*/ | 93 | /* unz_file_info_interntal contain internal info about a file in zipfile*/ |
94 | typedef struct unz_file_info_internal_s | 94 | typedef struct unz_file_info_internal_s |
@@ -798,7 +798,8 @@ extern int ZEXPORT unzGoToNextFile (file) | |||
798 | s=(unz_s*)file; | 798 | s=(unz_s*)file; |
799 | if (!s->current_file_ok) | 799 | if (!s->current_file_ok) |
800 | return UNZ_END_OF_LIST_OF_FILE; | 800 | return UNZ_END_OF_LIST_OF_FILE; |
801 | if (s->num_file+1==s->gi.number_entry) | 801 | if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */ |
802 | if (s->num_file+1==s->gi.number_entry) | ||
802 | return UNZ_END_OF_LIST_OF_FILE; | 803 | return UNZ_END_OF_LIST_OF_FILE; |
803 | 804 | ||
804 | s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + | 805 | s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + |
@@ -1244,9 +1245,15 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) | |||
1244 | 1245 | ||
1245 | pfile_in_zip_read_info->stream.avail_out = (uInt)len; | 1246 | pfile_in_zip_read_info->stream.avail_out = (uInt)len; |
1246 | 1247 | ||
1247 | if (len>pfile_in_zip_read_info->rest_read_uncompressed) | 1248 | if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && |
1249 | (!(pfile_in_zip_read_info->raw))) | ||
1248 | pfile_in_zip_read_info->stream.avail_out = | 1250 | pfile_in_zip_read_info->stream.avail_out = |
1249 | (uInt)pfile_in_zip_read_info->rest_read_uncompressed; | 1251 | (uInt)pfile_in_zip_read_info->rest_read_uncompressed; |
1252 | |||
1253 | if ((len>pfile_in_zip_read_info->rest_read_compressed) && | ||
1254 | (pfile_in_zip_read_info->raw)) | ||
1255 | pfile_in_zip_read_info->stream.avail_out = | ||
1256 | (uInt)pfile_in_zip_read_info->rest_read_compressed; | ||
1250 | 1257 | ||
1251 | while (pfile_in_zip_read_info->stream.avail_out>0) | 1258 | while (pfile_in_zip_read_info->stream.avail_out>0) |
1252 | { | 1259 | { |
@@ -1339,6 +1346,9 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) | |||
1339 | */ | 1346 | */ |
1340 | err=inflate(&pfile_in_zip_read_info->stream,flush); | 1347 | err=inflate(&pfile_in_zip_read_info->stream,flush); |
1341 | 1348 | ||
1349 | if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) | ||
1350 | err = Z_DATA_ERROR; | ||
1351 | |||
1342 | uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; | 1352 | uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; |
1343 | uOutThis = uTotalOutAfter-uTotalOutBefore; | 1353 | uOutThis = uTotalOutAfter-uTotalOutBefore; |
1344 | 1354 | ||
@@ -1461,7 +1471,7 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) | |||
1461 | 1471 | ||
1462 | if (ZREAD(pfile_in_zip_read_info->z_filefunc, | 1472 | if (ZREAD(pfile_in_zip_read_info->z_filefunc, |
1463 | pfile_in_zip_read_info->filestream, | 1473 | pfile_in_zip_read_info->filestream, |
1464 | buf,size_to_read)!=size_to_read) | 1474 | buf,read_now)!=read_now) |
1465 | return UNZ_ERRNO; | 1475 | return UNZ_ERRNO; |
1466 | 1476 | ||
1467 | return (int)read_now; | 1477 | return (int)read_now; |
@@ -1544,3 +1554,40 @@ extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) | |||
1544 | *(szComment+s->gi.size_comment)='\0'; | 1554 | *(szComment+s->gi.size_comment)='\0'; |
1545 | return (int)uReadThis; | 1555 | return (int)uReadThis; |
1546 | } | 1556 | } |
1557 | |||
1558 | /* Additions by RX '2004 */ | ||
1559 | extern uLong ZEXPORT unzGetOffset (file) | ||
1560 | unzFile file; | ||
1561 | { | ||
1562 | unz_s* s; | ||
1563 | |||
1564 | if (file==NULL) | ||
1565 | return UNZ_PARAMERROR; | ||
1566 | s=(unz_s*)file; | ||
1567 | if (!s->current_file_ok) | ||
1568 | return 0; | ||
1569 | if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff) | ||
1570 | if (s->num_file==s->gi.number_entry) | ||
1571 | return 0; | ||
1572 | return s->pos_in_central_dir; | ||
1573 | } | ||
1574 | |||
1575 | extern int ZEXPORT unzSetOffset (file, pos) | ||
1576 | unzFile file; | ||
1577 | uLong pos; | ||
1578 | { | ||
1579 | unz_s* s; | ||
1580 | int err; | ||
1581 | |||
1582 | if (file==NULL) | ||
1583 | return UNZ_PARAMERROR; | ||
1584 | s=(unz_s*)file; | ||
1585 | |||
1586 | s->pos_in_central_dir = pos; | ||
1587 | s->num_file = s->gi.number_entry; /* hack */ | ||
1588 | err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, | ||
1589 | &s->cur_file_info_internal, | ||
1590 | NULL,0,NULL,0,NULL,0); | ||
1591 | s->current_file_ok = (err == UNZ_OK); | ||
1592 | return err; | ||
1593 | } | ||