From e8b715640ee0bd3bde44ae3a6bc5994385a02ab4 Mon Sep 17 00:00:00 2001 From: Gianluca Bertani Date: Tue, 18 Jun 2013 23:22:59 +0200 Subject: [PATCH] Fixed use of 64 bit I/O APIs --- MiniZip/ioapi.c | 17 ++++++++++++++--- MiniZip/ioapi.h | 6 +----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/MiniZip/ioapi.c b/MiniZip/ioapi.c index 49958f6..01a8c02 100644 --- a/MiniZip/ioapi.c +++ b/MiniZip/ioapi.c @@ -16,6 +16,17 @@ #include "ioapi.h" +#if defined(__APPLE__) || defined(IOAPI_NO_64) +// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions +#define FOPEN64(filename, mode) fopen(filename, mode) +#define FTELLO64(stream) ftello(stream) +#define FSEEKO64(stream, offset, origin) fseeko(stream, offset, origin) +#else +#define FOPEN64(filename, mode) fopen64(filename, mode) +#define FTELLO64(stream) ftello64(stream) +#define FSEEKO64(stream, offset, origin) fseeko64(stream, offset, origin) +#endif + voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) { if (pfilefunc->zfile_func64.zopen64_file != NULL) @@ -112,7 +123,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 = FOPEN64((const char*)filename, mode_fopen); return file; } @@ -142,7 +153,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 = FTELLO64((FILE *)stream); return ret; } @@ -188,7 +199,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T } ret = 0; - if(fseeko64((FILE *)stream, offset, fseek_origin) != 0) + if(FSEEKO64((FILE *)stream, offset, fseek_origin) != 0) ret = -1; return ret; diff --git a/MiniZip/ioapi.h b/MiniZip/ioapi.h index 3632653..0e5cbc3 100644 --- a/MiniZip/ioapi.h +++ b/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. @@ -44,10 +44,6 @@ #include #include "zlib.h" -#ifdef __APPLE__ -# define USE_FILE32API -#endif - #if defined(USE_FILE32API) #define fopen64 fopen #define ftello64 ftell