|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
Read unzip.h for more info
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
@ -134,9 +134,7 @@ typedef struct
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local int unzlocal_getByte(fin,pi)
|
|
|
|
|
FILE *fin;
|
|
|
|
|
int *pi;
|
|
|
|
|
local int unzlocal_getByte(FILE * fin,int* pi)
|
|
|
|
|
{
|
|
|
|
|
unsigned char c;
|
|
|
|
|
int err = fread(&c, 1, 1, fin);
|
|
|
|
@ -158,9 +156,7 @@ local int unzlocal_getByte(fin,pi)
|
|
|
|
|
/* ===========================================================================
|
|
|
|
|
Reads a long in LSB order from the given gz_stream. Sets
|
|
|
|
|
*/
|
|
|
|
|
local int unzlocal_getShort (fin,pX)
|
|
|
|
|
FILE* fin;
|
|
|
|
|
uLong *pX;
|
|
|
|
|
local int unzlocal_getShort (FILE* fin,uLong *pX)
|
|
|
|
|
{
|
|
|
|
|
uLong x ;
|
|
|
|
|
int i;
|
|
|
|
@ -180,9 +176,7 @@ local int unzlocal_getShort (fin,pX)
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local int unzlocal_getLong (fin,pX)
|
|
|
|
|
FILE* fin;
|
|
|
|
|
uLong *pX;
|
|
|
|
|
local int unzlocal_getLong (FILE* fin,uLong *pX)
|
|
|
|
|
{
|
|
|
|
|
uLong x ;
|
|
|
|
|
int i;
|
|
|
|
@ -212,9 +206,7 @@ local int unzlocal_getLong (fin,pX)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* My own strcmpi / strcasecmp */
|
|
|
|
|
local int strcmpcasenosensitive_internal (fileName1,fileName2)
|
|
|
|
|
const char* fileName1;
|
|
|
|
|
const char* fileName2;
|
|
|
|
|
local int strcmpcasenosensitive_internal (const char* fileName1,const char* fileName2)
|
|
|
|
|
{
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
@ -255,10 +247,7 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2)
|
|
|
|
|
(like 1 on Unix, 2 on Windows)
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity)
|
|
|
|
|
const char* fileName1;
|
|
|
|
|
const char* fileName2;
|
|
|
|
|
int iCaseSensitivity;
|
|
|
|
|
extern int ZEXPORT unzStringFileNameCompare (const char* fileName1,const char* fileName2,int iCaseSensitivity)
|
|
|
|
|
{
|
|
|
|
|
if (iCaseSensitivity==0)
|
|
|
|
|
iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
|
|
|
|
@ -275,8 +264,7 @@ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivit
|
|
|
|
|
Locate the Central directory of a zipfile (at the end, just before
|
|
|
|
|
the global comment)
|
|
|
|
|
*/
|
|
|
|
|
local uLong unzlocal_SearchCentralDir(fin)
|
|
|
|
|
FILE *fin;
|
|
|
|
|
local uLong unzlocal_SearchCentralDir(FILE *fin)
|
|
|
|
|
{
|
|
|
|
|
unsigned char* buf;
|
|
|
|
|
uLong uSizeFile;
|
|
|
|
@ -340,8 +328,7 @@ local uLong unzlocal_SearchCentralDir(fin)
|
|
|
|
|
Else, the return value is a unzFile Handle, usable with other function
|
|
|
|
|
of this unzip package.
|
|
|
|
|
*/
|
|
|
|
|
extern unzFile ZEXPORT unzOpen(path)
|
|
|
|
|
const char *path;
|
|
|
|
|
extern unzFile ZEXPORT unzOpen(const char *path)
|
|
|
|
|
{
|
|
|
|
|
unz_s us;
|
|
|
|
|
unz_s *s;
|
|
|
|
@ -440,8 +427,7 @@ extern unzFile ZEXPORT unzOpen(path)
|
|
|
|
|
If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
|
|
|
|
|
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
|
|
|
|
return UNZ_OK if there is no problem. */
|
|
|
|
|
extern int ZEXPORT unzClose (file)
|
|
|
|
|
unzFile file;
|
|
|
|
|
extern int ZEXPORT unzClose (unzFile file)
|
|
|
|
|
{
|
|
|
|
|
unz_s* s;
|
|
|
|
|
if (file==NULL)
|
|
|
|
@ -461,9 +447,7 @@ extern int ZEXPORT unzClose (file)
|
|
|
|
|
Write info about the ZipFile in the *pglobal_info structure.
|
|
|
|
|
No preparation of the structure is needed
|
|
|
|
|
return UNZ_OK if there is no problem. */
|
|
|
|
|
extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
|
|
|
|
|
unzFile file;
|
|
|
|
|
unz_global_info *pglobal_info;
|
|
|
|
|
extern int ZEXPORT unzGetGlobalInfo (unzFile file,unz_global_info *pglobal_info)
|
|
|
|
|
{
|
|
|
|
|
unz_s* s;
|
|
|
|
|
if (file==NULL)
|
|
|
|
@ -477,9 +461,7 @@ extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
|
|
|
|
|
/*
|
|
|
|
|
Translate date/time from Dos format to tm_unz (readable more easilty)
|
|
|
|
|
*/
|
|
|
|
|
local void unzlocal_DosDateToTmuDate (ulDosDate, ptm)
|
|
|
|
|
uLong ulDosDate;
|
|
|
|
|
tm_unz* ptm;
|
|
|
|
|
local void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz* ptm)
|
|
|
|
|
{
|
|
|
|
|
uLong uDate;
|
|
|
|
|
uDate = (uLong)(ulDosDate>>16);
|
|
|
|
@ -506,21 +488,12 @@ local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
|
|
|
|
|
char *szComment,
|
|
|
|
|
uLong commentBufferSize));
|
|
|
|
|
|
|
|
|
|
local int unzlocal_GetCurrentFileInfoInternal (file,
|
|
|
|
|
pfile_info,
|
|
|
|
|
pfile_info_internal,
|
|
|
|
|
szFileName, fileNameBufferSize,
|
|
|
|
|
extraField, extraFieldBufferSize,
|
|
|
|
|
szComment, commentBufferSize)
|
|
|
|
|
unzFile file;
|
|
|
|
|
unz_file_info *pfile_info;
|
|
|
|
|
unz_file_info_internal *pfile_info_internal;
|
|
|
|
|
char *szFileName;
|
|
|
|
|
uLong fileNameBufferSize;
|
|
|
|
|
void *extraField;
|
|
|
|
|
uLong extraFieldBufferSize;
|
|
|
|
|
char *szComment;
|
|
|
|
|
uLong commentBufferSize;
|
|
|
|
|
local int unzlocal_GetCurrentFileInfoInternal (unzFile file,
|
|
|
|
|
unz_file_info *pfile_info,
|
|
|
|
|
unz_file_info_internal *pfile_info_internal,
|
|
|
|
|
char *szFileName, uLong fileNameBufferSize,
|
|
|
|
|
void *extraField, uLong extraFieldBufferSize,
|
|
|
|
|
char *szComment, uLong commentBufferSize)
|
|
|
|
|
{
|
|
|
|
|
unz_s* s;
|
|
|
|
|
unz_file_info file_info;
|
|
|
|
@ -677,19 +650,11 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
|
|
|
|
|
No preparation of the structure is needed
|
|
|
|
|
return UNZ_OK if there is no problem.
|
|
|
|
|
*/
|
|
|
|
|
extern int ZEXPORT unzGetCurrentFileInfo (file,
|
|
|
|
|
pfile_info,
|
|
|
|
|
szFileName, fileNameBufferSize,
|
|
|
|
|
extraField, extraFieldBufferSize,
|
|
|
|
|
szComment, commentBufferSize)
|
|
|
|
|
unzFile file;
|
|
|
|
|
unz_file_info *pfile_info;
|
|
|
|
|
char *szFileName;
|
|
|
|
|
uLong fileNameBufferSize;
|
|
|
|
|
void *extraField;
|
|
|
|
|
uLong extraFieldBufferSize;
|
|
|
|
|
char *szComment;
|
|
|
|
|
uLong commentBufferSize;
|
|
|
|
|
extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
|
|
|
|
|
unz_file_info *pfile_info,
|
|
|
|
|
char *szFileName, uLong fileNameBufferSize,
|
|
|
|
|
void *extraField, uLong extraFieldBufferSize,
|
|
|
|
|
char *szComment, uLong commentBufferSize)
|
|
|
|
|
{
|
|
|
|
|
return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
|
|
|
|
|
szFileName,fileNameBufferSize,
|
|
|
|
@ -701,8 +666,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (file,
|
|
|
|
|
Set the current file of the zipfile to the first file.
|
|
|
|
|
return UNZ_OK if there is no problem
|
|
|
|
|
*/
|
|
|
|
|
extern int ZEXPORT unzGoToFirstFile (file)
|
|
|
|
|
unzFile file;
|
|
|
|
|
extern int ZEXPORT unzGoToFirstFile (unzFile file)
|
|
|
|
|
{
|
|
|
|
|
int err=UNZ_OK;
|
|
|
|
|
unz_s* s;
|
|
|
|
@ -724,8 +688,7 @@ extern int ZEXPORT unzGoToFirstFile (file)
|
|
|
|
|
return UNZ_OK if there is no problem
|
|
|
|
|
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
|
|
|
|
*/
|
|
|
|
|
extern int ZEXPORT unzGoToNextFile (file)
|
|
|
|
|
unzFile file;
|
|
|
|
|
extern int ZEXPORT unzGoToNextFile (unzFile file)
|
|
|
|
|
{
|
|
|
|
|
unz_s* s;
|
|
|
|
|
int err;
|
|
|
|
@ -757,10 +720,7 @@ extern int ZEXPORT unzGoToNextFile (file)
|
|
|
|
|
UNZ_OK if the file is found. It becomes the current file.
|
|
|
|
|
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
|
|
|
|
*/
|
|
|
|
|
extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
|
|
|
|
|
unzFile file;
|
|
|
|
|
const char *szFileName;
|
|
|
|
|
int iCaseSensitivity;
|
|
|
|
|
extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
|
|
|
|
|
{
|
|
|
|
|
unz_s* s;
|
|
|
|
|
int err;
|
|
|
|
@ -810,13 +770,9 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
|
|
|
|
|
store in *piSizeVar the size of extra info in local header
|
|
|
|
|
(filename and size of extra field data)
|
|
|
|
|
*/
|
|
|
|
|
local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
|
|
|
|
|
poffset_local_extrafield,
|
|
|
|
|
psize_local_extrafield)
|
|
|
|
|
unz_s* s;
|
|
|
|
|
uInt* piSizeVar;
|
|
|
|
|
uLong *poffset_local_extrafield;
|
|
|
|
|
uInt *psize_local_extrafield;
|
|
|
|
|
local int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s,uInt* piSizeVar,
|
|
|
|
|
uLong *poffset_local_extrafield,
|
|
|
|
|
uInt *psize_local_extrafield)
|
|
|
|
|
{
|
|
|
|
|
uLong uMagic,uData,uFlags;
|
|
|
|
|
uLong size_filename;
|
|
|
|
@ -902,8 +858,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
|
|
|
|
|
Open for reading data the current file in the zipfile.
|
|
|
|
|
If there is no error and the file is opened, the return value is UNZ_OK.
|
|
|
|
|
*/
|
|
|
|
|
extern int ZEXPORT unzOpenCurrentFile (file)
|
|
|
|
|
unzFile file;
|
|
|
|
|
extern int ZEXPORT unzOpenCurrentFile (unzFile file)
|
|
|
|
|
{
|
|
|
|
|
int err=UNZ_OK;
|
|
|
|
|
int Store;
|
|
|
|
@ -1003,10 +958,7 @@ extern int ZEXPORT unzOpenCurrentFile (file)
|
|
|
|
|
return <0 with error code if there is an error
|
|
|
|
|
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
|
|
|
|
*/
|
|
|
|
|
extern int ZEXPORT unzReadCurrentFile (file, buf, len)
|
|
|
|
|
unzFile file;
|
|
|
|
|
voidp buf;
|
|
|
|
|
unsigned len;
|
|
|
|
|
extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
|
|
|
|
|
{
|
|
|
|
|
int err=UNZ_OK;
|
|
|
|
|
uInt iRead = 0;
|
|
|
|
@ -1130,8 +1082,7 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
|
|
|
|
|
/*
|
|
|
|
|
Give the current position in uncompressed data
|
|
|
|
|
*/
|
|
|
|
|
extern z_off_t ZEXPORT unztell (file)
|
|
|
|
|
unzFile file;
|
|
|
|
|
extern z_off_t ZEXPORT unztell (unzFile file)
|
|
|
|
|
{
|
|
|
|
|
unz_s* s;
|
|
|
|
|
file_in_zip_read_info_s* pfile_in_zip_read_info;
|
|
|
|
@ -1150,8 +1101,7 @@ extern z_off_t ZEXPORT unztell (file)
|
|
|
|
|
/*
|
|
|
|
|
return 1 if the end of file was reached, 0 elsewhere
|
|
|
|
|
*/
|
|
|
|
|
extern int ZEXPORT unzeof (file)
|
|
|
|
|
unzFile file;
|
|
|
|
|
extern int ZEXPORT unzeof (unzFile file)
|
|
|
|
|
{
|
|
|
|
|
unz_s* s;
|
|
|
|
|
file_in_zip_read_info_s* pfile_in_zip_read_info;
|
|
|
|
@ -1183,10 +1133,7 @@ extern int ZEXPORT unzeof (file)
|
|
|
|
|
the return value is the number of bytes copied in buf, or (if <0)
|
|
|
|
|
the error code
|
|
|
|
|
*/
|
|
|
|
|
extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
|
|
|
|
|
unzFile file;
|
|
|
|
|
voidp buf;
|
|
|
|
|
unsigned len;
|
|
|
|
|
extern int ZEXPORT unzGetLocalExtrafield (unzFile file,voidp buf,unsigned len)
|
|
|
|
|
{
|
|
|
|
|
unz_s* s;
|
|
|
|
|
file_in_zip_read_info_s* pfile_in_zip_read_info;
|
|
|
|
@ -1230,8 +1177,7 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
|
|
|
|
|
Close the file in zip opened with unzipOpenCurrentFile
|
|
|
|
|
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
|
|
|
|
*/
|
|
|
|
|
extern int ZEXPORT unzCloseCurrentFile (file)
|
|
|
|
|
unzFile file;
|
|
|
|
|
extern int ZEXPORT unzCloseCurrentFile (unzFile file)
|
|
|
|
|
{
|
|
|
|
|
int err=UNZ_OK;
|
|
|
|
|
|
|
|
|
@ -1272,10 +1218,7 @@ extern int ZEXPORT unzCloseCurrentFile (file)
|
|
|
|
|
uSizeBuf is the size of the szComment buffer.
|
|
|
|
|
return the number of byte copied or an error code <0
|
|
|
|
|
*/
|
|
|
|
|
extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
|
|
|
|
|
unzFile file;
|
|
|
|
|
char *szComment;
|
|
|
|
|
uLong uSizeBuf;
|
|
|
|
|
extern int ZEXPORT unzGetGlobalComment (unzFile file, char *szComment, uLong uSizeBuf)
|
|
|
|
|
{
|
|
|
|
|
unz_s* s;
|
|
|
|
|
uLong uReadThis ;
|