summaryrefslogtreecommitdiff
path: root/contrib/minizip
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-11 11:04:49 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-11 11:04:49 -0700
commit10daf0d4d7815447799d555d04d30325836e1d44 (patch)
tree75579fbe11e42dc3197acca53f5f887ac3808b57 /contrib/minizip
parent9712272c78b9d9c93746d9c8e156a3728c65ca72 (diff)
downloadzlib-10daf0d4d7815447799d555d04d30325836e1d44.tar.gz
zlib 1.2.5.1v1.2.5.1
Diffstat (limited to 'contrib/minizip')
-rw-r--r--contrib/minizip/ioapi.c18
-rw-r--r--contrib/minizip/ioapi.h3
-rw-r--r--contrib/minizip/miniunz.c38
-rw-r--r--contrib/minizip/minizip.c39
-rw-r--r--contrib/minizip/unzip.c2
5 files changed, 69 insertions, 31 deletions
diff --git a/contrib/minizip/ioapi.c b/contrib/minizip/ioapi.c
index 49958f6..d4bc020 100644
--- a/contrib/minizip/ioapi.c
+++ b/contrib/minizip/ioapi.c
@@ -14,6 +14,18 @@
#define _CRT_SECURE_NO_WARNINGS
#endif
+#ifdef __APPLE__
+// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
+#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
+#define FTELLO_FUNC(stream) ftello(stream)
+#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
+#else
+#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
+#define FTELLO_FUNC(stream) ftello64(stream)
+#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
+#endif
+
+
#include "ioapi.h"
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
@@ -112,7 +124,7 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
mode_fopen = "wb";
if ((filename!=NULL) && (mode_fopen != NULL))
- file = fopen64((const char*)filename, mode_fopen);
+ file = FOPEN_FUNC((const char*)filename, mode_fopen);
return file;
}
@@ -142,7 +154,7 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
{
ZPOS64_T ret;
- ret = ftello64((FILE *)stream);
+ ret = FTELLO_FUNC((FILE *)stream);
return ret;
}
@@ -188,7 +200,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
}
ret = 0;
- if(fseeko64((FILE *)stream, offset, fseek_origin) != 0)
+ if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0)
ret = -1;
return ret;
diff --git a/contrib/minizip/ioapi.h b/contrib/minizip/ioapi.h
index 8309c4c..f6dce26 100644
--- a/contrib/minizip/ioapi.h
+++ b/contrib/minizip/ioapi.h
@@ -21,7 +21,7 @@
#ifndef _ZLIBIOAPI64_H
#define _ZLIBIOAPI64_H
-#if (!defined(_WIN32)) && (!defined(WIN32))
+#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
// Linux needs this to support file operation on files larger then 4+GB
// But might need better if/def to select just the platforms that needs them.
@@ -38,6 +38,7 @@
#ifndef _FILE_OFFSET_BIT
#define _FILE_OFFSET_BIT 64
#endif
+
#endif
#include <stdio.h>
diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c
index 9ed009f..3d65401 100644
--- a/contrib/minizip/miniunz.c
+++ b/contrib/minizip/miniunz.c
@@ -12,7 +12,7 @@
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
*/
-#ifndef _WIN32
+#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
#ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64
#endif
@@ -27,6 +27,18 @@
#endif
#endif
+#ifdef __APPLE__
+// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
+#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
+#define FTELLO_FUNC(stream) ftello(stream)
+#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
+#else
+#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
+#define FTELLO_FUNC(stream) ftello64(stream)
+#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
+#endif
+
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -34,14 +46,15 @@
#include <errno.h>
#include <fcntl.h>
-#ifdef unix
-# include <unistd.h>
-# include <utime.h>
-#else
+#ifdef _WIN32
# include <direct.h>
# include <io.h>
+#else
+# include <unistd.h>
+# include <utime.h>
#endif
+
#include "unzip.h"
#define CASESENSITIVITY (0)
@@ -84,7 +97,7 @@ void change_file_date(filename,dosdate,tmu_date)
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
CloseHandle(hFile);
#else
-#ifdef unix
+#ifdef unix || __APPLE__
struct utimbuf ut;
struct tm newdate;
newdate.tm_sec = tmu_date.tm_sec;
@@ -114,10 +127,10 @@ int mymkdir(dirname)
int ret=0;
#ifdef _WIN32
ret = _mkdir(dirname);
-#else
-#ifdef unix
+#elif unix
+ ret = mkdir (dirname,0775);
+#elif __APPLE__
ret = mkdir (dirname,0775);
-#endif
#endif
return ret;
}
@@ -364,7 +377,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
{
char rep=0;
FILE* ftestexist;
- ftestexist = fopen64(write_filename,"rb");
+ ftestexist = FOPEN_FUNC(write_filename,"rb");
if (ftestexist!=NULL)
{
fclose(ftestexist);
@@ -395,8 +408,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
if ((skip==0) && (err==UNZ_OK))
{
- fout=fopen64(write_filename,"wb");
-
+ fout=FOPEN_FUNC(write_filename,"wb");
/* some zipfile don't contain directory alone before file */
if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
(filename_withoutpath!=(char*)filename_inzip))
@@ -405,7 +417,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
*(filename_withoutpath-1)='\0';
makedir(write_filename);
*(filename_withoutpath-1)=c;
- fout=fopen64(write_filename,"wb");
+ fout=FOPEN_FUNC(write_filename,"wb");
}
if (fout==NULL)
diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c
index 7a4fa5a..de63e37 100644
--- a/contrib/minizip/minizip.c
+++ b/contrib/minizip/minizip.c
@@ -13,7 +13,7 @@
*/
-#ifndef _WIN32
+#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
#ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64
#endif
@@ -28,6 +28,19 @@
#endif
#endif
+#ifdef __APPLE__
+// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
+#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
+#define FTELLO_FUNC(stream) ftello(stream)
+#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
+#else
+#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
+#define FTELLO_FUNC(stream) ftello64(stream)
+#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
+#endif
+
+
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -35,14 +48,14 @@
#include <errno.h>
#include <fcntl.h>
-#ifdef unix
+#ifdef _WIN32
+# include <direct.h>
+# include <io.h>
+#else
# include <unistd.h>
# include <utime.h>
# include <sys/types.h>
# include <sys/stat.h>
-#else
-# include <direct.h>
-# include <io.h>
#endif
#include "zip.h"
@@ -81,7 +94,7 @@ uLong filetime(f, tmzip, dt)
return ret;
}
#else
-#ifdef unix
+#ifdef unix || __APPLE__
uLong filetime(f, tmzip, dt)
char *f; /* name of file to get info on */
tm_zip *tmzip; /* return value: access, modific. and creation times */
@@ -142,7 +155,7 @@ int check_exist_file(filename)
{
FILE* ftestexist;
int ret = 1;
- ftestexist = fopen64(filename,"rb");
+ ftestexist = FOPEN_FUNC(filename,"rb");
if (ftestexist==NULL)
ret = 0;
else
@@ -173,7 +186,8 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
{
unsigned long calculate_crc=0;
int err=ZIP_OK;
- FILE * fin = fopen64(filenameinzip,"rb");
+ FILE * fin = FOPEN_FUNC(filenameinzip,"rb");
+
unsigned long size_read = 0;
unsigned long total_read = 0;
if (fin==NULL)
@@ -211,13 +225,12 @@ int isLargeFile(const char* filename)
{
int largeFile = 0;
ZPOS64_T pos = 0;
- FILE* pFile = fopen64(filename, "rb");
+ FILE* pFile = FOPEN_FUNC(filename, "rb");
if(pFile != NULL)
{
- int n = fseeko64(pFile, 0, SEEK_END);
-
- pos = ftello64(pFile);
+ int n = FSEEKO_FUNC(pFile, 0, SEEK_END);
+ pos = FTELLO_FUNC(pFile);
printf("File : %s is %lld bytes\n", filename, pos);
@@ -447,7 +460,7 @@ int main(argc,argv)
printf("error in opening %s in zipfile\n",filenameinzip);
else
{
- fin = fopen64(filenameinzip,"rb");
+ fin = FOPEN_FUNC(filenameinzip,"rb");
if (fin==NULL)
{
err=ZIP_ERRNO;
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c
index 7617f41..587a2a1 100644
--- a/contrib/minizip/unzip.c
+++ b/contrib/minizip/unzip.c
@@ -1145,7 +1145,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
szFileName,fileNameBufferSize,
extraField,extraFieldBufferSize,
szComment,commentBufferSize);
- if (err==UNZ_OK)
+ if ((err==UNZ_OK) && (pfile_info != NULL))
{
pfile_info->version = file_info64.version;
pfile_info->version_needed = file_info64.version_needed;