diff options
Diffstat (limited to 'contrib/minizip/zip.c')
-rw-r--r-- | contrib/minizip/zip.c | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c index 698dcec..3c34fc8 100644 --- a/contrib/minizip/zip.c +++ b/contrib/minizip/zip.c | |||
@@ -1,22 +1,23 @@ | |||
1 | /* zip.c -- IO on .zip files using zlib | 1 | /* zip.c -- IO on .zip files using zlib |
2 | Version 1.1, January 7th, 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 for Zip64 support | 7 | Modifications for Zip64 support |
8 | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) | 8 | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) |
9 | 9 | ||
10 | For more info read MiniZip_info.txt | 10 | For more info read MiniZip_info.txt |
11 | 11 | ||
12 | Changes | 12 | Changes |
13 | Okt-2009 - Mathias Svensson - Remove old C style function prototypes | 13 | Oct-2009 - Mathias Svensson - Remove old C style function prototypes |
14 | Okt-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives | 14 | Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives |
15 | Okt-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions. | 15 | Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions. |
16 | Okt-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data | 16 | Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data |
17 | It is used when recreting zip archive with RAW when deleting items from a zip. | 17 | It is used when recreting zip archive with RAW when deleting items from a zip. |
18 | ZIP64 data is automaticly added to items that needs it, and existing ZIP64 data need to be removed. | 18 | ZIP64 data is automaticly added to items that needs it, and existing ZIP64 data need to be removed. |
19 | Okt-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required) | 19 | Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required) |
20 | Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer | ||
20 | 21 | ||
21 | */ | 22 | */ |
22 | 23 | ||
@@ -1526,22 +1527,22 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s | |||
1526 | zi->ci.stream.avail_in = 0; | 1527 | zi->ci.stream.avail_in = 0; |
1527 | 1528 | ||
1528 | if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) | 1529 | if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) |
1529 | { | 1530 | { |
1530 | while (err==ZIP_OK) | 1531 | while (err==ZIP_OK) |
1531 | { | 1532 | { |
1532 | uLong uTotalOutBefore; | 1533 | uLong uTotalOutBefore; |
1533 | if (zi->ci.stream.avail_out == 0) | 1534 | if (zi->ci.stream.avail_out == 0) |
1534 | { | 1535 | { |
1535 | if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) | 1536 | if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) |
1536 | err = ZIP_ERRNO; | 1537 | err = ZIP_ERRNO; |
1537 | zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; | 1538 | zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; |
1538 | zi->ci.stream.next_out = zi->ci.buffered_data; | 1539 | zi->ci.stream.next_out = zi->ci.buffered_data; |
1539 | } | 1540 | } |
1540 | uTotalOutBefore = zi->ci.stream.total_out; | 1541 | uTotalOutBefore = zi->ci.stream.total_out; |
1541 | err=deflate(&zi->ci.stream, Z_FINISH); | 1542 | err=deflate(&zi->ci.stream, Z_FINISH); |
1542 | zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; | 1543 | zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; |
1543 | } | 1544 | } |
1544 | } | 1545 | } |
1545 | else if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) | 1546 | else if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) |
1546 | { | 1547 | { |
1547 | #ifdef HAVE_BZIP2 | 1548 | #ifdef HAVE_BZIP2 |
@@ -1573,10 +1574,10 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s | |||
1573 | err=ZIP_OK; /* this is normal */ | 1574 | err=ZIP_OK; /* this is normal */ |
1574 | 1575 | ||
1575 | if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) | 1576 | if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) |
1576 | { | 1577 | { |
1577 | if (zip64FlushWriteBuffer(zi)==ZIP_ERRNO) | 1578 | if (zip64FlushWriteBuffer(zi)==ZIP_ERRNO) |
1578 | err = ZIP_ERRNO; | 1579 | err = ZIP_ERRNO; |
1579 | } | 1580 | } |
1580 | 1581 | ||
1581 | if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) | 1582 | if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) |
1582 | { | 1583 | { |
@@ -1589,9 +1590,9 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s | |||
1589 | else if((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) | 1590 | else if((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) |
1590 | { | 1591 | { |
1591 | int tmperr = BZ2_bzCompressEnd(&zi->ci.bstream); | 1592 | int tmperr = BZ2_bzCompressEnd(&zi->ci.bstream); |
1592 | if (err==ZIP_OK) | 1593 | if (err==ZIP_OK) |
1593 | err = tmperr; | 1594 | err = tmperr; |
1594 | zi->ci.stream_initialised = 0; | 1595 | zi->ci.stream_initialised = 0; |
1595 | } | 1596 | } |
1596 | #endif | 1597 | #endif |
1597 | 1598 | ||
@@ -1851,7 +1852,7 @@ int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, | |||
1851 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4); | 1852 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4); |
1852 | } | 1853 | } |
1853 | else | 1854 | else |
1854 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); | 1855 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); |
1855 | } | 1856 | } |
1856 | 1857 | ||
1857 | return err; | 1858 | return err; |