summaryrefslogtreecommitdiff
path: root/contrib/minizip/miniunz.c
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/miniunz.c
parent9712272c78b9d9c93746d9c8e156a3728c65ca72 (diff)
downloadzlib-1.2.5.1.tar.gz
zlib-1.2.5.1.tar.bz2
zlib-1.2.5.1.zip
zlib 1.2.5.1v1.2.5.1
Diffstat (limited to 'contrib/minizip/miniunz.c')
-rw-r--r--contrib/minizip/miniunz.c38
1 files changed, 25 insertions, 13 deletions
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)