Merged 1.5 update from Andre, maybe.
This commit is contained in:
commit
1e3fb61d76
50 changed files with 5573 additions and 3442 deletions
|
@ -1,9 +1,9 @@
|
|||
/* crypt.h -- base code for crypt/uncrypt ZIPfile
|
||||
|
||||
|
||||
Version 1.01h, December 28th, 2009
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2009 Gilles Vollant
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This code is a modified version of crypting code in Infozip distribution
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* ioapi.c -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
|
||||
Version 1.01h, December 28th, 2009
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2009 Gilles Vollant
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -141,8 +141,7 @@ long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
|
|||
default: return -1;
|
||||
}
|
||||
ret = 0;
|
||||
if (fseek((FILE *)stream, offset, fseek_origin) != 0)
|
||||
ret = -1;
|
||||
fseek((FILE *)stream, offset, fseek_origin);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
|
||||
Version 1.01h, December 28th, 2009
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2009 Gilles Vollant
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
*/
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* unzip.c -- IO for uncompress .zip files using zlib
|
||||
Version 1.01h, December 28th, 2009
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2009 Gilles Vollant
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
Read unzip.h for more info
|
||||
*/
|
||||
|
@ -103,9 +103,6 @@ typedef struct
|
|||
{
|
||||
char *read_buffer; /* internal buffer for compressed data */
|
||||
z_stream stream; /* zLib stream structure for inflate */
|
||||
#ifdef HAVE_BZIP2
|
||||
bz_stream bstream; /* bzLib stream structure for bziped */
|
||||
#endif
|
||||
|
||||
uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/
|
||||
uLong stream_initialised; /* flag set if stream structure is initialised*/
|
||||
|
@ -207,7 +204,7 @@ local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX)
|
|||
uLong *pX;
|
||||
{
|
||||
uLong x ;
|
||||
int i = 0;
|
||||
int i;
|
||||
int err;
|
||||
|
||||
err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
|
||||
|
@ -235,7 +232,7 @@ local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX)
|
|||
uLong *pX;
|
||||
{
|
||||
uLong x ;
|
||||
int i = 0;
|
||||
int i;
|
||||
int err;
|
||||
|
||||
err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
|
||||
|
@ -494,11 +491,8 @@ extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def)
|
|||
|
||||
|
||||
s=(unz_s*)ALLOC(sizeof(unz_s));
|
||||
if (s!=NULL)
|
||||
{
|
||||
*s=us;
|
||||
unzGoToFirstFile((unzFile)s);
|
||||
}
|
||||
*s=us;
|
||||
unzGoToFirstFile((unzFile)s);
|
||||
return (unzFile)s;
|
||||
}
|
||||
|
||||
|
@ -614,12 +608,10 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
|
|||
|
||||
/* we check the magic */
|
||||
if (err==UNZ_OK)
|
||||
{
|
||||
if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
|
||||
err=UNZ_ERRNO;
|
||||
else if (uMagic!=0x02014b50)
|
||||
err=UNZ_BADZIPFILE;
|
||||
}
|
||||
|
||||
if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
|
||||
err=UNZ_ERRNO;
|
||||
|
@ -696,13 +688,10 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
|
|||
uSizeRead = extraFieldBufferSize;
|
||||
|
||||
if (lSeek!=0)
|
||||
{
|
||||
if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
||||
lSeek=0;
|
||||
else
|
||||
err=UNZ_ERRNO;
|
||||
}
|
||||
|
||||
if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
|
||||
if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead)
|
||||
err=UNZ_ERRNO;
|
||||
|
@ -724,13 +713,10 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
|
|||
uSizeRead = commentBufferSize;
|
||||
|
||||
if (lSeek!=0)
|
||||
{
|
||||
if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
|
||||
lSeek=0;
|
||||
else
|
||||
err=UNZ_ERRNO;
|
||||
}
|
||||
|
||||
if ((file_info.size_file_comment>0) && (commentBufferSize>0))
|
||||
if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
|
||||
err=UNZ_ERRNO;
|
||||
|
@ -991,12 +977,10 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
|
|||
|
||||
|
||||
if (err==UNZ_OK)
|
||||
{
|
||||
if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
|
||||
err=UNZ_ERRNO;
|
||||
else if (uMagic!=0x04034b50)
|
||||
err=UNZ_BADZIPFILE;
|
||||
}
|
||||
|
||||
if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
|
||||
err=UNZ_ERRNO;
|
||||
|
@ -1013,9 +997,6 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
|
|||
err=UNZ_BADZIPFILE;
|
||||
|
||||
if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
|
||||
/* #ifdef HAVE_BZIP2 */
|
||||
(s->cur_file_info.compression_method!=Z_BZIP2ED) &&
|
||||
/* #endif */
|
||||
(s->cur_file_info.compression_method!=Z_DEFLATED))
|
||||
err=UNZ_BADZIPFILE;
|
||||
|
||||
|
@ -1130,9 +1111,6 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
|
|||
}
|
||||
|
||||
if ((s->cur_file_info.compression_method!=0) &&
|
||||
/* #ifdef HAVE_BZIP2 */
|
||||
(s->cur_file_info.compression_method!=Z_BZIP2ED) &&
|
||||
/* #endif */
|
||||
(s->cur_file_info.compression_method!=Z_DEFLATED))
|
||||
err=UNZ_BADZIPFILE;
|
||||
|
||||
|
@ -1146,34 +1124,6 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
|
|||
|
||||
pfile_in_zip_read_info->stream.total_out = 0;
|
||||
|
||||
if ((s->cur_file_info.compression_method==Z_BZIP2ED) &&
|
||||
(!raw))
|
||||
{
|
||||
#ifdef HAVE_BZIP2
|
||||
pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0;
|
||||
pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
|
||||
pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
|
||||
pfile_in_zip_read_info->bstream.state = (voidpf)0;
|
||||
|
||||
pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
|
||||
pfile_in_zip_read_info->stream.zfree = (free_func)0;
|
||||
pfile_in_zip_read_info->stream.opaque = (voidpf)0;
|
||||
pfile_in_zip_read_info->stream.next_in = (voidpf)0;
|
||||
pfile_in_zip_read_info->stream.avail_in = 0;
|
||||
|
||||
err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);
|
||||
if (err == Z_OK)
|
||||
pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
|
||||
else
|
||||
{
|
||||
TRYFREE(pfile_in_zip_read_info);
|
||||
return err;
|
||||
}
|
||||
#else
|
||||
pfile_in_zip_read_info->raw=1;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
if ((s->cur_file_info.compression_method==Z_DEFLATED) &&
|
||||
(!raw))
|
||||
{
|
||||
|
@ -1185,7 +1135,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
|
|||
|
||||
err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
|
||||
if (err == Z_OK)
|
||||
pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
|
||||
pfile_in_zip_read_info->stream_initialised=1;
|
||||
else
|
||||
{
|
||||
TRYFREE(pfile_in_zip_read_info);
|
||||
|
@ -1213,8 +1163,6 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
|
|||
|
||||
s->pfile_in_zip_read = pfile_in_zip_read_info;
|
||||
|
||||
s->encrypted = 0;
|
||||
|
||||
# ifndef NOUNCRYPT
|
||||
if (password != NULL)
|
||||
{
|
||||
|
@ -1386,53 +1334,6 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
|
|||
iRead += uDoCopy;
|
||||
}
|
||||
else
|
||||
if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED)
|
||||
{
|
||||
#ifdef HAVE_BZIP2
|
||||
uLong uTotalOutBefore,uTotalOutAfter;
|
||||
const Bytef *bufBefore;
|
||||
uLong uOutThis;
|
||||
|
||||
pfile_in_zip_read_info->bstream.next_in = pfile_in_zip_read_info->stream.next_in;
|
||||
pfile_in_zip_read_info->bstream.avail_in = pfile_in_zip_read_info->stream.avail_in;
|
||||
pfile_in_zip_read_info->bstream.total_in_lo32 = pfile_in_zip_read_info->stream.total_in;
|
||||
pfile_in_zip_read_info->bstream.total_in_hi32 = 0;
|
||||
pfile_in_zip_read_info->bstream.next_out = pfile_in_zip_read_info->stream.next_out;
|
||||
pfile_in_zip_read_info->bstream.avail_out = pfile_in_zip_read_info->stream.avail_out;
|
||||
pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out;
|
||||
pfile_in_zip_read_info->bstream.total_out_hi32 = 0;
|
||||
|
||||
uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;
|
||||
bufBefore = pfile_in_zip_read_info->bstream.next_out;
|
||||
|
||||
err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);
|
||||
|
||||
uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;
|
||||
uOutThis = uTotalOutAfter-uTotalOutBefore;
|
||||
|
||||
pfile_in_zip_read_info->crc32 =
|
||||
crc32(pfile_in_zip_read_info->crc32,bufBefore,
|
||||
(uInt)(uOutThis));
|
||||
|
||||
pfile_in_zip_read_info->rest_read_uncompressed -=
|
||||
uOutThis;
|
||||
|
||||
iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
|
||||
|
||||
pfile_in_zip_read_info->stream.next_in = pfile_in_zip_read_info->bstream.next_in;
|
||||
pfile_in_zip_read_info->stream.avail_in = pfile_in_zip_read_info->bstream.avail_in;
|
||||
pfile_in_zip_read_info->stream.total_in = pfile_in_zip_read_info->bstream.total_in_lo32;
|
||||
pfile_in_zip_read_info->stream.next_out = pfile_in_zip_read_info->bstream.next_out;
|
||||
pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;
|
||||
pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;
|
||||
|
||||
if (err==BZ_STREAM_END)
|
||||
return (iRead==0) ? UNZ_EOF : iRead;
|
||||
if (err!=BZ_OK)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
uLong uTotalOutBefore,uTotalOutAfter;
|
||||
const Bytef *bufBefore;
|
||||
|
@ -1611,12 +1512,8 @@ extern int ZEXPORT unzCloseCurrentFile (file)
|
|||
|
||||
TRYFREE(pfile_in_zip_read_info->read_buffer);
|
||||
pfile_in_zip_read_info->read_buffer = NULL;
|
||||
if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
|
||||
if (pfile_in_zip_read_info->stream_initialised)
|
||||
inflateEnd(&pfile_in_zip_read_info->stream);
|
||||
#ifdef HAVE_BZIP2
|
||||
else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED)
|
||||
BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);
|
||||
#endif
|
||||
|
||||
pfile_in_zip_read_info->stream_initialised = 0;
|
||||
TRYFREE(pfile_in_zip_read_info);
|
||||
|
@ -1637,6 +1534,7 @@ extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
|
|||
char *szComment;
|
||||
uLong uSizeBuf;
|
||||
{
|
||||
int err=UNZ_OK;
|
||||
unz_s* s;
|
||||
uLong uReadThis ;
|
||||
if (file==NULL)
|
||||
|
@ -1669,7 +1567,7 @@ extern uLong ZEXPORT unzGetOffset (file)
|
|||
unz_s* s;
|
||||
|
||||
if (file==NULL)
|
||||
return 0;
|
||||
return UNZ_PARAMERROR;
|
||||
s=(unz_s*)file;
|
||||
if (!s->current_file_ok)
|
||||
return 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 1.01h, December 28th, 2009
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2009 Gilles Vollant
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
|
@ -57,12 +57,6 @@ extern "C" {
|
|||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BZIP2
|
||||
#include "bzlib.h"
|
||||
#endif
|
||||
|
||||
#define Z_BZIP2ED 12
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* zip.c -- IO on .zip files using zlib
|
||||
Version 1.01h, December 28th, 2009
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
27 Dec 2004 Rolf Kalbermatter
|
||||
Modification to zipOpen2 to support globalComment retrieval.
|
||||
|
||||
Copyright (C) 1998-2009 Gilles Vollant
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
Read zip.h for more info
|
||||
*/
|
||||
|
@ -320,9 +320,9 @@ local uLong ziplocal_TmzDateToDosDate(ptm,dosDate)
|
|||
uLong dosDate;
|
||||
{
|
||||
uLong year = (uLong)ptm->tm_year;
|
||||
if (year>=1980)
|
||||
if (year>1980)
|
||||
year-=1980;
|
||||
else if (year>=80)
|
||||
else if (year>80)
|
||||
year-=80;
|
||||
return
|
||||
(uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) |
|
||||
|
@ -373,7 +373,7 @@ local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX)
|
|||
uLong *pX;
|
||||
{
|
||||
uLong x ;
|
||||
int i = 0;
|
||||
int i;
|
||||
int err;
|
||||
|
||||
err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
|
||||
|
@ -401,7 +401,7 @@ local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX)
|
|||
uLong *pX;
|
||||
{
|
||||
uLong x ;
|
||||
int i = 0;
|
||||
int i;
|
||||
int err;
|
||||
|
||||
err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
|
||||
|
@ -432,69 +432,67 @@ local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX)
|
|||
/*
|
||||
Locate the Central directory of a zipfile (at the end, just before
|
||||
the global comment)
|
||||
Fix from Riccardo Cohen
|
||||
*/
|
||||
local uLong ziplocal_SearchCentralDir OF((
|
||||
const zlib_filefunc_def* pzlib_filefunc_def,
|
||||
voidpf filestream));
|
||||
|
||||
local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream)
|
||||
const zlib_filefunc_def* pzlib_filefunc_def;
|
||||
voidpf filestream;
|
||||
const zlib_filefunc_def* pzlib_filefunc_def;
|
||||
voidpf filestream;
|
||||
{
|
||||
unsigned char* buf;
|
||||
uLong uSizeFile;
|
||||
uLong uBackRead;
|
||||
uLong uMaxBack=0xffff; /* maximum size of global comment */
|
||||
uLong uPosFound=0;
|
||||
unsigned char* buf;
|
||||
uLong uSizeFile;
|
||||
uLong uBackRead;
|
||||
uLong uMaxBack=0xffff; /* maximum size of global comment */
|
||||
uLong uPosFound=0;
|
||||
|
||||
if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
|
||||
return 0;
|
||||
if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
|
||||
return 0;
|
||||
|
||||
|
||||
uSizeFile = ZTELL(*pzlib_filefunc_def,filestream);
|
||||
uSizeFile = ZTELL(*pzlib_filefunc_def,filestream);
|
||||
|
||||
if (uMaxBack>uSizeFile)
|
||||
uMaxBack = uSizeFile;
|
||||
if (uMaxBack>uSizeFile)
|
||||
uMaxBack = uSizeFile;
|
||||
|
||||
buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
|
||||
if (buf==NULL)
|
||||
return 0;
|
||||
buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
|
||||
if (buf==NULL)
|
||||
return 0;
|
||||
|
||||
uBackRead = 4;
|
||||
while (uBackRead<uMaxBack)
|
||||
{
|
||||
uLong uReadSize,uReadPos ;
|
||||
int i;
|
||||
if (uBackRead+BUFREADCOMMENT>uMaxBack)
|
||||
uBackRead = uMaxBack;
|
||||
else
|
||||
uBackRead+=BUFREADCOMMENT;
|
||||
uReadPos = uSizeFile-uBackRead ;
|
||||
uBackRead = 4;
|
||||
while (uBackRead<uMaxBack)
|
||||
{
|
||||
uLong uReadSize,uReadPos ;
|
||||
int i;
|
||||
if (uBackRead+BUFREADCOMMENT>uMaxBack)
|
||||
uBackRead = uMaxBack;
|
||||
else
|
||||
uBackRead+=BUFREADCOMMENT;
|
||||
uReadPos = uSizeFile-uBackRead ;
|
||||
|
||||
uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
|
||||
(BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
|
||||
if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
|
||||
break;
|
||||
uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
|
||||
(BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
|
||||
if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
|
||||
break;
|
||||
|
||||
if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
|
||||
break;
|
||||
if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
|
||||
break;
|
||||
|
||||
for (i=(int)uReadSize-3; (i--)>0;)
|
||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
||||
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
|
||||
{
|
||||
uPosFound = uReadPos+i;
|
||||
break;
|
||||
}
|
||||
for (i=(int)uReadSize-3; (i--)>0;)
|
||||
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
|
||||
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
|
||||
{
|
||||
uPosFound = uReadPos+i;
|
||||
break;
|
||||
}
|
||||
|
||||
if (uPosFound!=0)
|
||||
break;
|
||||
}
|
||||
TRYFREE(buf);
|
||||
return uPosFound;
|
||||
if (uPosFound!=0)
|
||||
break;
|
||||
}
|
||||
TRYFREE(buf);
|
||||
return uPosFound;
|
||||
}
|
||||
|
||||
#endif /* !NO_ADDFILEINEXISTINGZIP*/
|
||||
|
||||
/************************************************************/
|
||||
|
@ -523,8 +521,6 @@ extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc
|
|||
|
||||
if (ziinit.filestream == NULL)
|
||||
return NULL;
|
||||
if (append == APPEND_STATUS_CREATEAFTER)
|
||||
ZSEEK(ziinit.z_filefunc,ziinit.filestream,0,SEEK_END);
|
||||
ziinit.begin_pos = ZTELL(ziinit.z_filefunc,ziinit.filestream);
|
||||
ziinit.in_opened_file_inzip = 0;
|
||||
ziinit.ci.stream_initialised = 0;
|
||||
|
@ -562,10 +558,9 @@ extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc
|
|||
uLong size_comment;
|
||||
|
||||
central_pos = ziplocal_SearchCentralDir(&ziinit.z_filefunc,ziinit.filestream);
|
||||
/* disable to allow appending to empty ZIP archive
|
||||
if (central_pos==0)
|
||||
err=ZIP_ERRNO;
|
||||
*/
|
||||
|
||||
if (ZSEEK(ziinit.z_filefunc, ziinit.filestream,
|
||||
central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
|
||||
err=ZIP_ERRNO;
|
||||
|
@ -620,7 +615,7 @@ extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc
|
|||
|
||||
if (size_comment>0)
|
||||
{
|
||||
ziinit.globalcomment = (char*)ALLOC(size_comment+1);
|
||||
ziinit.globalcomment = ALLOC(size_comment+1);
|
||||
if (ziinit.globalcomment)
|
||||
{
|
||||
size_comment = ZREAD(ziinit.z_filefunc, ziinit.filestream,ziinit.globalcomment,size_comment);
|
||||
|
@ -692,12 +687,12 @@ extern zipFile ZEXPORT zipOpen (pathname, append)
|
|||
return zipOpen2(pathname,append,NULL,NULL);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip4 (file, filename, zipfi,
|
||||
extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, versionMadeBy, flagBase)
|
||||
password, crcForCrypting)
|
||||
zipFile file;
|
||||
const char* filename;
|
||||
const zip_fileinfo* zipfi;
|
||||
|
@ -714,8 +709,6 @@ extern int ZEXPORT zipOpenNewFileInZip4 (file, filename, zipfi,
|
|||
int strategy;
|
||||
const char* password;
|
||||
uLong crcForCrypting;
|
||||
uLong versionMadeBy;
|
||||
uLong flagBase;
|
||||
{
|
||||
zip_internal* zi;
|
||||
uInt size_filename;
|
||||
|
@ -762,7 +755,7 @@ extern int ZEXPORT zipOpenNewFileInZip4 (file, filename, zipfi,
|
|||
else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate);
|
||||
}
|
||||
|
||||
zi->ci.flag = flagBase;
|
||||
zi->ci.flag = 0;
|
||||
if ((level==8) || (level==9))
|
||||
zi->ci.flag |= 2;
|
||||
if ((level==2))
|
||||
|
@ -785,7 +778,7 @@ extern int ZEXPORT zipOpenNewFileInZip4 (file, filename, zipfi,
|
|||
|
||||
ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4);
|
||||
/* version info */
|
||||
ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)versionMadeBy,2);
|
||||
ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2);
|
||||
ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2);
|
||||
ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2);
|
||||
ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2);
|
||||
|
@ -864,7 +857,6 @@ extern int ZEXPORT zipOpenNewFileInZip4 (file, filename, zipfi,
|
|||
zi->ci.stream.next_out = zi->ci.buffered_data;
|
||||
zi->ci.stream.total_in = 0;
|
||||
zi->ci.stream.total_out = 0;
|
||||
zi->ci.stream.data_type = Z_BINARY;
|
||||
|
||||
if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
|
||||
{
|
||||
|
@ -920,46 +912,14 @@ extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi,
|
|||
int level;
|
||||
int raw;
|
||||
{
|
||||
return zipOpenNewFileInZip4 (file, filename, zipfi,
|
||||
return zipOpenNewFileInZip3 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0);
|
||||
NULL, 0);
|
||||
}
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting)
|
||||
zipFile file;
|
||||
const char* filename;
|
||||
const zip_fileinfo* zipfi;
|
||||
const void* extrafield_local;
|
||||
uInt size_extrafield_local;
|
||||
const void* extrafield_global;
|
||||
uInt size_extrafield_global;
|
||||
const char* comment;
|
||||
int method;
|
||||
int level;
|
||||
int raw;
|
||||
int windowBits;
|
||||
int memLevel;
|
||||
int strategy;
|
||||
const char* password;
|
||||
uLong crcForCrypting;
|
||||
{
|
||||
return zipOpenNewFileInZip4 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, raw,
|
||||
windowBits, memLevel, strategy,
|
||||
password, crcForCrypting, VERSIONMADEBY, 0);
|
||||
}
|
||||
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
|
@ -975,12 +935,10 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
|
|||
int method;
|
||||
int level;
|
||||
{
|
||||
return zipOpenNewFileInZip4 (file, filename, zipfi,
|
||||
return zipOpenNewFileInZip2 (file, filename, zipfi,
|
||||
extrafield_local, size_extrafield_local,
|
||||
extrafield_global, size_extrafield_global,
|
||||
comment, method, level, 0,
|
||||
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
|
||||
NULL, 0, VERSIONMADEBY, 0);
|
||||
comment, method, level, 0);
|
||||
}
|
||||
|
||||
local int zipFlushWriteBuffer(zi)
|
||||
|
@ -1020,9 +978,9 @@ extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
|
|||
if (zi->in_opened_file_inzip == 0)
|
||||
return ZIP_PARAMERROR;
|
||||
|
||||
zi->ci.stream.next_in = (Bytef*)buf;
|
||||
zi->ci.stream.next_in = (void*)buf;
|
||||
zi->ci.stream.avail_in = len;
|
||||
zi->ci.crc32 = crc32(zi->ci.crc32,buf,(uInt)len);
|
||||
zi->ci.crc32 = crc32(zi->ci.crc32,buf,len);
|
||||
|
||||
while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
|
||||
{
|
||||
|
@ -1112,9 +1070,7 @@ extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32)
|
|||
|
||||
if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
|
||||
{
|
||||
int tmp_err=deflateEnd(&zi->ci.stream);
|
||||
if (err == ZIP_OK)
|
||||
err = tmp_err;
|
||||
err=deflateEnd(&zi->ci.stream);
|
||||
zi->ci.stream_initialised = 0;
|
||||
}
|
||||
|
||||
|
@ -1217,7 +1173,7 @@ extern int ZEXPORT zipClose (file, global_comment)
|
|||
ldi = ldi->next_datablock;
|
||||
}
|
||||
}
|
||||
free_linkedlist(&(zi->central_dir));
|
||||
free_datablock(zi->central_dir.first_block);
|
||||
|
||||
if (err==ZIP_OK) /* Magic End */
|
||||
err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* zip.h -- IO for compress .zip files using zlib
|
||||
Version 1.01h, December 28th, 2009
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2009 Gilles Vollant
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
|
@ -191,7 +191,8 @@ extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
|
|||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting));
|
||||
uLong crcForCtypting));
|
||||
|
||||
/*
|
||||
Same than zipOpenNewFileInZip2, except
|
||||
windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
|
||||
|
@ -199,29 +200,6 @@ extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
|
|||
crcForCtypting : crc of file to compress (needed for crypting)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
const void* extrafield_local,
|
||||
uInt size_extrafield_local,
|
||||
const void* extrafield_global,
|
||||
uInt size_extrafield_global,
|
||||
const char* comment,
|
||||
int method,
|
||||
int level,
|
||||
int raw,
|
||||
int windowBits,
|
||||
int memLevel,
|
||||
int strategy,
|
||||
const char* password,
|
||||
uLong crcForCrypting,
|
||||
uLong versionMadeBy,
|
||||
uLong flagBase));
|
||||
/*
|
||||
Same than zipOpenNewFileInZip4, except
|
||||
versionMadeBy : value for Version made by field
|
||||
flag : value for flag field (compression level info will be added)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
|
||||
const void* buf,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue