diff options
Diffstat (limited to '')
-rw-r--r-- | contrib/minizip/minizip.c | 39 |
1 files changed, 26 insertions, 13 deletions
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 @@ | |||
13 | */ | 13 | */ |
14 | 14 | ||
15 | 15 | ||
16 | #ifndef _WIN32 | 16 | #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) |
17 | #ifndef __USE_FILE_OFFSET64 | 17 | #ifndef __USE_FILE_OFFSET64 |
18 | #define __USE_FILE_OFFSET64 | 18 | #define __USE_FILE_OFFSET64 |
19 | #endif | 19 | #endif |
@@ -28,6 +28,19 @@ | |||
28 | #endif | 28 | #endif |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #ifdef __APPLE__ | ||
32 | // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions | ||
33 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) | ||
34 | #define FTELLO_FUNC(stream) ftello(stream) | ||
35 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) | ||
36 | #else | ||
37 | #define FOPEN_FUNC(filename, mode) fopen64(filename, mode) | ||
38 | #define FTELLO_FUNC(stream) ftello64(stream) | ||
39 | #define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) | ||
40 | #endif | ||
41 | |||
42 | |||
43 | |||
31 | #include <stdio.h> | 44 | #include <stdio.h> |
32 | #include <stdlib.h> | 45 | #include <stdlib.h> |
33 | #include <string.h> | 46 | #include <string.h> |
@@ -35,14 +48,14 @@ | |||
35 | #include <errno.h> | 48 | #include <errno.h> |
36 | #include <fcntl.h> | 49 | #include <fcntl.h> |
37 | 50 | ||
38 | #ifdef unix | 51 | #ifdef _WIN32 |
52 | # include <direct.h> | ||
53 | # include <io.h> | ||
54 | #else | ||
39 | # include <unistd.h> | 55 | # include <unistd.h> |
40 | # include <utime.h> | 56 | # include <utime.h> |
41 | # include <sys/types.h> | 57 | # include <sys/types.h> |
42 | # include <sys/stat.h> | 58 | # include <sys/stat.h> |
43 | #else | ||
44 | # include <direct.h> | ||
45 | # include <io.h> | ||
46 | #endif | 59 | #endif |
47 | 60 | ||
48 | #include "zip.h" | 61 | #include "zip.h" |
@@ -81,7 +94,7 @@ uLong filetime(f, tmzip, dt) | |||
81 | return ret; | 94 | return ret; |
82 | } | 95 | } |
83 | #else | 96 | #else |
84 | #ifdef unix | 97 | #ifdef unix || __APPLE__ |
85 | uLong filetime(f, tmzip, dt) | 98 | uLong filetime(f, tmzip, dt) |
86 | char *f; /* name of file to get info on */ | 99 | char *f; /* name of file to get info on */ |
87 | tm_zip *tmzip; /* return value: access, modific. and creation times */ | 100 | tm_zip *tmzip; /* return value: access, modific. and creation times */ |
@@ -142,7 +155,7 @@ int check_exist_file(filename) | |||
142 | { | 155 | { |
143 | FILE* ftestexist; | 156 | FILE* ftestexist; |
144 | int ret = 1; | 157 | int ret = 1; |
145 | ftestexist = fopen64(filename,"rb"); | 158 | ftestexist = FOPEN_FUNC(filename,"rb"); |
146 | if (ftestexist==NULL) | 159 | if (ftestexist==NULL) |
147 | ret = 0; | 160 | ret = 0; |
148 | else | 161 | else |
@@ -173,7 +186,8 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne | |||
173 | { | 186 | { |
174 | unsigned long calculate_crc=0; | 187 | unsigned long calculate_crc=0; |
175 | int err=ZIP_OK; | 188 | int err=ZIP_OK; |
176 | FILE * fin = fopen64(filenameinzip,"rb"); | 189 | FILE * fin = FOPEN_FUNC(filenameinzip,"rb"); |
190 | |||
177 | unsigned long size_read = 0; | 191 | unsigned long size_read = 0; |
178 | unsigned long total_read = 0; | 192 | unsigned long total_read = 0; |
179 | if (fin==NULL) | 193 | if (fin==NULL) |
@@ -211,13 +225,12 @@ int isLargeFile(const char* filename) | |||
211 | { | 225 | { |
212 | int largeFile = 0; | 226 | int largeFile = 0; |
213 | ZPOS64_T pos = 0; | 227 | ZPOS64_T pos = 0; |
214 | FILE* pFile = fopen64(filename, "rb"); | 228 | FILE* pFile = FOPEN_FUNC(filename, "rb"); |
215 | 229 | ||
216 | if(pFile != NULL) | 230 | if(pFile != NULL) |
217 | { | 231 | { |
218 | int n = fseeko64(pFile, 0, SEEK_END); | 232 | int n = FSEEKO_FUNC(pFile, 0, SEEK_END); |
219 | 233 | pos = FTELLO_FUNC(pFile); | |
220 | pos = ftello64(pFile); | ||
221 | 234 | ||
222 | printf("File : %s is %lld bytes\n", filename, pos); | 235 | printf("File : %s is %lld bytes\n", filename, pos); |
223 | 236 | ||
@@ -447,7 +460,7 @@ int main(argc,argv) | |||
447 | printf("error in opening %s in zipfile\n",filenameinzip); | 460 | printf("error in opening %s in zipfile\n",filenameinzip); |
448 | else | 461 | else |
449 | { | 462 | { |
450 | fin = fopen64(filenameinzip,"rb"); | 463 | fin = FOPEN_FUNC(filenameinzip,"rb"); |
451 | if (fin==NULL) | 464 | if (fin==NULL) |
452 | { | 465 | { |
453 | err=ZIP_ERRNO; | 466 | err=ZIP_ERRNO; |