Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: third_party/zlib/contrib/minizip/miniunz.c

Issue 2079313002: Revert of Update Zlib to version 1.2.8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/zlib/contrib/minizip/iowin32.c ('k') | third_party/zlib/contrib/minizip/minizip.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 miniunz.c 2 miniunz.c
3 Version 1.1, February 14h, 2010 3 Version 1.1, February 14h, 2010
4 sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizi p.html ) 4 sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizi p.html )
5 5
6 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage. com/zLibDll/minizip.html ) 6 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage. com/zLibDll/minizip.html )
7 7
8 Modifications of Unzip for Zip64 8 Modifications of Unzip for Zip64
9 Copyright (C) 2007-2008 Even Rouault 9 Copyright (C) 2007-2008 Even Rouault
10 10
11 Modifications for Zip64 support on both zip and unzip 11 Modifications for Zip64 support on both zip and unzip
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 #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) 15 #ifndef _WIN32
16 #ifndef __USE_FILE_OFFSET64 16 #ifndef __USE_FILE_OFFSET64
17 #define __USE_FILE_OFFSET64 17 #define __USE_FILE_OFFSET64
18 #endif 18 #endif
19 #ifndef __USE_LARGEFILE64 19 #ifndef __USE_LARGEFILE64
20 #define __USE_LARGEFILE64 20 #define __USE_LARGEFILE64
21 #endif 21 #endif
22 #ifndef _LARGEFILE64_SOURCE 22 #ifndef _LARGEFILE64_SOURCE
23 #define _LARGEFILE64_SOURCE 23 #define _LARGEFILE64_SOURCE
24 #endif 24 #endif
25 #ifndef _FILE_OFFSET_BIT 25 #ifndef _FILE_OFFSET_BIT
26 #define _FILE_OFFSET_BIT 64 26 #define _FILE_OFFSET_BIT 64
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 ne ed 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
42 #include <stdio.h> 30 #include <stdio.h>
43 #include <stdlib.h> 31 #include <stdlib.h>
44 #include <string.h> 32 #include <string.h>
45 #include <time.h> 33 #include <time.h>
46 #include <errno.h> 34 #include <errno.h>
47 #include <fcntl.h> 35 #include <fcntl.h>
48 36
49 #ifdef _WIN32 37 #ifdef unix
38 # include <unistd.h>
39 # include <utime.h>
40 #else
50 # include <direct.h> 41 # include <direct.h>
51 # include <io.h> 42 # include <io.h>
52 #else
53 # include <unistd.h>
54 # include <utime.h>
55 #endif 43 #endif
56 44
57
58 #include "unzip.h" 45 #include "unzip.h"
59 46
60 #define CASESENSITIVITY (0) 47 #define CASESENSITIVITY (0)
61 #define WRITEBUFFERSIZE (8192) 48 #define WRITEBUFFERSIZE (8192)
62 #define MAXFILENAME (256) 49 #define MAXFILENAME (256)
63 50
64 #ifdef _WIN32 51 #ifdef _WIN32
65 #define USEWIN32IOAPI 52 #define USEWIN32IOAPI
66 #include "iowin32.h" 53 #include "iowin32.h"
67 #endif 54 #endif
(...skipping 22 matching lines...) Expand all
90 FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; 77 FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
91 78
92 hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE, 79 hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE,
93 0,NULL,OPEN_EXISTING,0,NULL); 80 0,NULL,OPEN_EXISTING,0,NULL);
94 GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite); 81 GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
95 DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal); 82 DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
96 LocalFileTimeToFileTime(&ftLocal,&ftm); 83 LocalFileTimeToFileTime(&ftLocal,&ftm);
97 SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); 84 SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
98 CloseHandle(hFile); 85 CloseHandle(hFile);
99 #else 86 #else
100 #ifdef unix || __APPLE__ 87 #ifdef unix
101 struct utimbuf ut; 88 struct utimbuf ut;
102 struct tm newdate; 89 struct tm newdate;
103 newdate.tm_sec = tmu_date.tm_sec; 90 newdate.tm_sec = tmu_date.tm_sec;
104 newdate.tm_min=tmu_date.tm_min; 91 newdate.tm_min=tmu_date.tm_min;
105 newdate.tm_hour=tmu_date.tm_hour; 92 newdate.tm_hour=tmu_date.tm_hour;
106 newdate.tm_mday=tmu_date.tm_mday; 93 newdate.tm_mday=tmu_date.tm_mday;
107 newdate.tm_mon=tmu_date.tm_mon; 94 newdate.tm_mon=tmu_date.tm_mon;
108 if (tmu_date.tm_year > 1900) 95 if (tmu_date.tm_year > 1900)
109 newdate.tm_year=tmu_date.tm_year - 1900; 96 newdate.tm_year=tmu_date.tm_year - 1900;
110 else 97 else
111 newdate.tm_year=tmu_date.tm_year ; 98 newdate.tm_year=tmu_date.tm_year ;
112 newdate.tm_isdst=-1; 99 newdate.tm_isdst=-1;
113 100
114 ut.actime=ut.modtime=mktime(&newdate); 101 ut.actime=ut.modtime=mktime(&newdate);
115 utime(filename,&ut); 102 utime(filename,&ut);
116 #endif 103 #endif
117 #endif 104 #endif
118 } 105 }
119 106
120 107
121 /* mymkdir and change_file_date are not 100 % portable 108 /* mymkdir and change_file_date are not 100 % portable
122 As I don't know well Unix, I wait feedback for the unix portion */ 109 As I don't know well Unix, I wait feedback for the unix portion */
123 110
124 int mymkdir(dirname) 111 int mymkdir(dirname)
125 const char* dirname; 112 const char* dirname;
126 { 113 {
127 int ret=0; 114 int ret=0;
128 #ifdef _WIN32 115 #ifdef _WIN32
129 ret = _mkdir(dirname); 116 ret = _mkdir(dirname);
130 #elif unix 117 #else
118 #ifdef unix
131 ret = mkdir (dirname,0775); 119 ret = mkdir (dirname,0775);
132 #elif __APPLE__ 120 #endif
133 ret = mkdir (dirname,0775);
134 #endif 121 #endif
135 return ret; 122 return ret;
136 } 123 }
137 124
138 int makedir (newdir) 125 int makedir (newdir)
139 char *newdir; 126 char *newdir;
140 { 127 {
141 char *buffer ; 128 char *buffer ;
142 char *p; 129 char *p;
143 int len = (int)strlen(newdir); 130 int len = (int)strlen(newdir);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 err = unzOpenCurrentFilePassword(uf,password); 357 err = unzOpenCurrentFilePassword(uf,password);
371 if (err!=UNZ_OK) 358 if (err!=UNZ_OK)
372 { 359 {
373 printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err); 360 printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err);
374 } 361 }
375 362
376 if (((*popt_overwrite)==0) && (err==UNZ_OK)) 363 if (((*popt_overwrite)==0) && (err==UNZ_OK))
377 { 364 {
378 char rep=0; 365 char rep=0;
379 FILE* ftestexist; 366 FILE* ftestexist;
380 ftestexist = FOPEN_FUNC(write_filename,"rb"); 367 ftestexist = fopen64(write_filename,"rb");
381 if (ftestexist!=NULL) 368 if (ftestexist!=NULL)
382 { 369 {
383 fclose(ftestexist); 370 fclose(ftestexist);
384 do 371 do
385 { 372 {
386 char answer[128]; 373 char answer[128];
387 int ret; 374 int ret;
388 375
389 printf("The file %s exists. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename); 376 printf("The file %s exists. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
390 ret = scanf("%1s",answer); 377 ret = scanf("%1s",answer);
(...skipping 10 matching lines...) Expand all
401 388
402 if (rep == 'N') 389 if (rep == 'N')
403 skip = 1; 390 skip = 1;
404 391
405 if (rep == 'A') 392 if (rep == 'A')
406 *popt_overwrite=1; 393 *popt_overwrite=1;
407 } 394 }
408 395
409 if ((skip==0) && (err==UNZ_OK)) 396 if ((skip==0) && (err==UNZ_OK))
410 { 397 {
411 fout=FOPEN_FUNC(write_filename,"wb"); 398 fout=fopen64(write_filename,"wb");
399
412 /* some zipfile don't contain directory alone before file */ 400 /* some zipfile don't contain directory alone before file */
413 if ((fout==NULL) && ((*popt_extract_without_path)==0) && 401 if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
414 (filename_withoutpath!=(char*)filename_inzip)) 402 (filename_withoutpath!=(char*)filename_inzip))
415 { 403 {
416 char c=*(filename_withoutpath-1); 404 char c=*(filename_withoutpath-1);
417 *(filename_withoutpath-1)='\0'; 405 *(filename_withoutpath-1)='\0';
418 makedir(write_filename); 406 makedir(write_filename);
419 *(filename_withoutpath-1)=c; 407 *(filename_withoutpath-1)=c;
420 fout=FOPEN_FUNC(write_filename,"wb"); 408 fout=fopen64(write_filename,"wb");
421 } 409 }
422 410
423 if (fout==NULL) 411 if (fout==NULL)
424 { 412 {
425 printf("error opening %s\n",write_filename); 413 printf("error opening %s\n",write_filename);
426 } 414 }
427 } 415 }
428 416
429 if (fout!=NULL) 417 if (fout!=NULL)
430 { 418 {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 if (filename_to_extract == NULL) 639 if (filename_to_extract == NULL)
652 ret_value = do_extract(uf, opt_do_extract_withoutpath, opt_overwrite , password); 640 ret_value = do_extract(uf, opt_do_extract_withoutpath, opt_overwrite , password);
653 else 641 else
654 ret_value = do_extract_onefile(uf, filename_to_extract, opt_do_extra ct_withoutpath, opt_overwrite, password); 642 ret_value = do_extract_onefile(uf, filename_to_extract, opt_do_extra ct_withoutpath, opt_overwrite, password);
655 } 643 }
656 644
657 unzClose(uf); 645 unzClose(uf);
658 646
659 return ret_value; 647 return ret_value;
660 } 648 }
OLDNEW
« no previous file with comments | « third_party/zlib/contrib/minizip/iowin32.c ('k') | third_party/zlib/contrib/minizip/minizip.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698