diff options
Diffstat (limited to 'contrib/minizip')
-rw-r--r-- | contrib/minizip/ioapi.c | 18 | ||||
-rw-r--r-- | contrib/minizip/ioapi.h | 3 | ||||
-rw-r--r-- | contrib/minizip/miniunz.c | 38 | ||||
-rw-r--r-- | contrib/minizip/minizip.c | 39 | ||||
-rw-r--r-- | contrib/minizip/unzip.c | 2 |
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 @@ | |||
14 | #define _CRT_SECURE_NO_WARNINGS | 14 | #define _CRT_SECURE_NO_WARNINGS |
15 | #endif | 15 | #endif |
16 | 16 | ||
17 | #ifdef __APPLE__ | ||
18 | // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions | ||
19 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) | ||
20 | #define FTELLO_FUNC(stream) ftello(stream) | ||
21 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) | ||
22 | #else | ||
23 | #define FOPEN_FUNC(filename, mode) fopen64(filename, mode) | ||
24 | #define FTELLO_FUNC(stream) ftello64(stream) | ||
25 | #define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) | ||
26 | #endif | ||
27 | |||
28 | |||
17 | #include "ioapi.h" | 29 | #include "ioapi.h" |
18 | 30 | ||
19 | voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) | 31 | 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, | |||
112 | mode_fopen = "wb"; | 124 | mode_fopen = "wb"; |
113 | 125 | ||
114 | if ((filename!=NULL) && (mode_fopen != NULL)) | 126 | if ((filename!=NULL) && (mode_fopen != NULL)) |
115 | file = fopen64((const char*)filename, mode_fopen); | 127 | file = FOPEN_FUNC((const char*)filename, mode_fopen); |
116 | return file; | 128 | return file; |
117 | } | 129 | } |
118 | 130 | ||
@@ -142,7 +154,7 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) | |||
142 | static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) | 154 | static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) |
143 | { | 155 | { |
144 | ZPOS64_T ret; | 156 | ZPOS64_T ret; |
145 | ret = ftello64((FILE *)stream); | 157 | ret = FTELLO_FUNC((FILE *)stream); |
146 | return ret; | 158 | return ret; |
147 | } | 159 | } |
148 | 160 | ||
@@ -188,7 +200,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T | |||
188 | } | 200 | } |
189 | ret = 0; | 201 | ret = 0; |
190 | 202 | ||
191 | if(fseeko64((FILE *)stream, offset, fseek_origin) != 0) | 203 | if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0) |
192 | ret = -1; | 204 | ret = -1; |
193 | 205 | ||
194 | return ret; | 206 | 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 @@ | |||
21 | #ifndef _ZLIBIOAPI64_H | 21 | #ifndef _ZLIBIOAPI64_H |
22 | #define _ZLIBIOAPI64_H | 22 | #define _ZLIBIOAPI64_H |
23 | 23 | ||
24 | #if (!defined(_WIN32)) && (!defined(WIN32)) | 24 | #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) |
25 | 25 | ||
26 | // Linux needs this to support file operation on files larger then 4+GB | 26 | // Linux needs this to support file operation on files larger then 4+GB |
27 | // But might need better if/def to select just the platforms that needs them. | 27 | // But might need better if/def to select just the platforms that needs them. |
@@ -38,6 +38,7 @@ | |||
38 | #ifndef _FILE_OFFSET_BIT | 38 | #ifndef _FILE_OFFSET_BIT |
39 | #define _FILE_OFFSET_BIT 64 | 39 | #define _FILE_OFFSET_BIT 64 |
40 | #endif | 40 | #endif |
41 | |||
41 | #endif | 42 | #endif |
42 | 43 | ||
43 | #include <stdio.h> | 44 | #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 @@ | |||
12 | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) | 12 | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #ifndef _WIN32 | 15 | #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) |
16 | #ifndef __USE_FILE_OFFSET64 | 16 | #ifndef __USE_FILE_OFFSET64 |
17 | #define __USE_FILE_OFFSET64 | 17 | #define __USE_FILE_OFFSET64 |
18 | #endif | 18 | #endif |
@@ -27,6 +27,18 @@ | |||
27 | #endif | 27 | #endif |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #ifdef __APPLE__ | ||
31 | // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions | ||
32 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) | ||
33 | #define FTELLO_FUNC(stream) ftello(stream) | ||
34 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) | ||
35 | #else | ||
36 | #define FOPEN_FUNC(filename, mode) fopen64(filename, mode) | ||
37 | #define FTELLO_FUNC(stream) ftello64(stream) | ||
38 | #define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) | ||
39 | #endif | ||
40 | |||
41 | |||
30 | #include <stdio.h> | 42 | #include <stdio.h> |
31 | #include <stdlib.h> | 43 | #include <stdlib.h> |
32 | #include <string.h> | 44 | #include <string.h> |
@@ -34,14 +46,15 @@ | |||
34 | #include <errno.h> | 46 | #include <errno.h> |
35 | #include <fcntl.h> | 47 | #include <fcntl.h> |
36 | 48 | ||
37 | #ifdef unix | 49 | #ifdef _WIN32 |
38 | # include <unistd.h> | ||
39 | # include <utime.h> | ||
40 | #else | ||
41 | # include <direct.h> | 50 | # include <direct.h> |
42 | # include <io.h> | 51 | # include <io.h> |
52 | #else | ||
53 | # include <unistd.h> | ||
54 | # include <utime.h> | ||
43 | #endif | 55 | #endif |
44 | 56 | ||
57 | |||
45 | #include "unzip.h" | 58 | #include "unzip.h" |
46 | 59 | ||
47 | #define CASESENSITIVITY (0) | 60 | #define CASESENSITIVITY (0) |
@@ -84,7 +97,7 @@ void change_file_date(filename,dosdate,tmu_date) | |||
84 | SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); | 97 | SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); |
85 | CloseHandle(hFile); | 98 | CloseHandle(hFile); |
86 | #else | 99 | #else |
87 | #ifdef unix | 100 | #ifdef unix || __APPLE__ |
88 | struct utimbuf ut; | 101 | struct utimbuf ut; |
89 | struct tm newdate; | 102 | struct tm newdate; |
90 | newdate.tm_sec = tmu_date.tm_sec; | 103 | newdate.tm_sec = tmu_date.tm_sec; |
@@ -114,10 +127,10 @@ int mymkdir(dirname) | |||
114 | int ret=0; | 127 | int ret=0; |
115 | #ifdef _WIN32 | 128 | #ifdef _WIN32 |
116 | ret = _mkdir(dirname); | 129 | ret = _mkdir(dirname); |
117 | #else | 130 | #elif unix |
118 | #ifdef unix | 131 | ret = mkdir (dirname,0775); |
132 | #elif __APPLE__ | ||
119 | ret = mkdir (dirname,0775); | 133 | ret = mkdir (dirname,0775); |
120 | #endif | ||
121 | #endif | 134 | #endif |
122 | return ret; | 135 | return ret; |
123 | } | 136 | } |
@@ -364,7 +377,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password) | |||
364 | { | 377 | { |
365 | char rep=0; | 378 | char rep=0; |
366 | FILE* ftestexist; | 379 | FILE* ftestexist; |
367 | ftestexist = fopen64(write_filename,"rb"); | 380 | ftestexist = FOPEN_FUNC(write_filename,"rb"); |
368 | if (ftestexist!=NULL) | 381 | if (ftestexist!=NULL) |
369 | { | 382 | { |
370 | fclose(ftestexist); | 383 | fclose(ftestexist); |
@@ -395,8 +408,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password) | |||
395 | 408 | ||
396 | if ((skip==0) && (err==UNZ_OK)) | 409 | if ((skip==0) && (err==UNZ_OK)) |
397 | { | 410 | { |
398 | fout=fopen64(write_filename,"wb"); | 411 | fout=FOPEN_FUNC(write_filename,"wb"); |
399 | |||
400 | /* some zipfile don't contain directory alone before file */ | 412 | /* some zipfile don't contain directory alone before file */ |
401 | if ((fout==NULL) && ((*popt_extract_without_path)==0) && | 413 | if ((fout==NULL) && ((*popt_extract_without_path)==0) && |
402 | (filename_withoutpath!=(char*)filename_inzip)) | 414 | (filename_withoutpath!=(char*)filename_inzip)) |
@@ -405,7 +417,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password) | |||
405 | *(filename_withoutpath-1)='\0'; | 417 | *(filename_withoutpath-1)='\0'; |
406 | makedir(write_filename); | 418 | makedir(write_filename); |
407 | *(filename_withoutpath-1)=c; | 419 | *(filename_withoutpath-1)=c; |
408 | fout=fopen64(write_filename,"wb"); | 420 | fout=FOPEN_FUNC(write_filename,"wb"); |
409 | } | 421 | } |
410 | 422 | ||
411 | if (fout==NULL) | 423 | 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 @@ | |||
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; |
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, | |||
1145 | szFileName,fileNameBufferSize, | 1145 | szFileName,fileNameBufferSize, |
1146 | extraField,extraFieldBufferSize, | 1146 | extraField,extraFieldBufferSize, |
1147 | szComment,commentBufferSize); | 1147 | szComment,commentBufferSize); |
1148 | if (err==UNZ_OK) | 1148 | if ((err==UNZ_OK) && (pfile_info != NULL)) |
1149 | { | 1149 | { |
1150 | pfile_info->version = file_info64.version; | 1150 | pfile_info->version = file_info64.version; |
1151 | pfile_info->version_needed = file_info64.version_needed; | 1151 | pfile_info->version_needed = file_info64.version_needed; |