[DEV] add basic interface of file offset for minizip

This commit is contained in:
Edouard DUPIN 2015-04-23 00:01:00 +02:00
parent 5089329162
commit d28591c2dc
2 changed files with 22 additions and 7 deletions

View File

@ -583,7 +583,8 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
*/
local unzFile unzOpenInternal (const void *path,
zlib_filefunc64_32_def* pzlib_filefunc64_32_def,
int is64bitOpenFunction)
int is64bitOpenFunction,
unsigned int basicOffset)
{
unz64_s us;
unz64_s *s;
@ -620,6 +621,14 @@ local unzFile unzOpenInternal (const void *path,
if (us.filestream==NULL)
return NULL;
if (ZSEEK64(us.z_filefunc,
us.filestream,
basicOffset,
ZLIB_FILEFUNC_SEEK_SET)!=0)
{
err=UNZ_ERRNO;
}
central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream);
if (central_pos)
{
@ -769,10 +778,10 @@ extern unzFile ZEXPORT unzOpen2 (const char *path,
{
zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def);
return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0);
return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0, 0);
}
else
return unzOpenInternal(path, NULL, 0);
return unzOpenInternal(path, NULL, 0, 0);
}
extern unzFile ZEXPORT unzOpen2_64 (const void *path,
@ -784,20 +793,25 @@ extern unzFile ZEXPORT unzOpen2_64 (const void *path,
zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
zlib_filefunc64_32_def_fill.ztell32_file = NULL;
zlib_filefunc64_32_def_fill.zseek32_file = NULL;
return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);
return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1, 0);
}
else
return unzOpenInternal(path, NULL, 1);
return unzOpenInternal(path, NULL, 1, 0);
}
extern unzFile ZEXPORT unzOpen (const char *path)
{
return unzOpenInternal(path, NULL, 0);
return unzOpenInternal(path, NULL, 0, 0);
}
extern unzFile ZEXPORT unzOpenOffset (const char *path, unsigned int basicOffset)
{
return unzOpenInternal(path, NULL, 0, basicOffset);
}
extern unzFile ZEXPORT unzOpen64 (const void *path)
{
return unzOpenInternal(path, NULL, 1);
return unzOpenInternal(path, NULL, 1, 0);
}
/*

View File

@ -164,6 +164,7 @@ extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
extern unzFile ZEXPORT unzOpen OF((const char *path));
extern unzFile ZEXPORT unzOpenOffset OF((const char *path, unsigned int basicOffset));
extern unzFile ZEXPORT unzOpen64 OF((const void *path));
/*
Open a Zip file. path contain the full pathname (by example,