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

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

Issue 2084863002: 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/miniunz.c ('k') | third_party/zlib/contrib/minizip/mztools.h » ('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 minizip.c 2 minizip.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 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
20 #ifndef __USE_LARGEFILE64 20 #ifndef __USE_LARGEFILE64
21 #define __USE_LARGEFILE64 21 #define __USE_LARGEFILE64
22 #endif 22 #endif
23 #ifndef _LARGEFILE64_SOURCE 23 #ifndef _LARGEFILE64_SOURCE
24 #define _LARGEFILE64_SOURCE 24 #define _LARGEFILE64_SOURCE
25 #endif 25 #endif
26 #ifndef _FILE_OFFSET_BIT 26 #ifndef _FILE_OFFSET_BIT
27 #define _FILE_OFFSET_BIT 64 27 #define _FILE_OFFSET_BIT 64
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 ne ed 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>
34 #include <time.h> 47 #include <time.h>
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"
49 62
50 #ifdef _WIN32 63 #ifdef _WIN32
51 #define USEWIN32IOAPI 64 #define USEWIN32IOAPI
52 #include "iowin32.h" 65 #include "iowin32.h"
53 #endif 66 #endif
54 67
55 68
(...skipping 18 matching lines...) Expand all
74 { 87 {
75 FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal); 88 FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal);
76 FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0); 89 FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0);
77 FindClose(hFind); 90 FindClose(hFind);
78 ret = 1; 91 ret = 1;
79 } 92 }
80 } 93 }
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 */
88 uLong *dt; /* dostime */ 101 uLong *dt; /* dostime */
89 { 102 {
90 int ret=0; 103 int ret=0;
91 struct stat s; /* results of stat() */ 104 struct stat s; /* results of stat() */
92 struct tm* filedate; 105 struct tm* filedate;
93 time_t tm_t=0; 106 time_t tm_t=0;
94 107
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 #endif 148 #endif
136 149
137 150
138 151
139 152
140 int check_exist_file(filename) 153 int check_exist_file(filename)
141 const char* filename; 154 const char* 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
149 fclose(ftestexist); 162 fclose(ftestexist);
150 return ret; 163 return ret;
151 } 164 }
152 165
153 void do_banner() 166 void do_banner()
154 { 167 {
155 printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vol lant\n"); 168 printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vol lant\n");
(...skipping 10 matching lines...) Expand all
166 " -9 Compress better\n\n" \ 179 " -9 Compress better\n\n" \
167 " -j exclude path. store only the file name.\n\n"); 180 " -j exclude path. store only the file name.\n\n");
168 } 181 }
169 182
170 /* calculate the CRC32 of a file, 183 /* calculate the CRC32 of a file,
171 because to encrypt a file, we need known the CRC32 of the file before */ 184 because to encrypt a file, we need known the CRC32 of the file before */
172 int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne d long* result_crc) 185 int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne d long* result_crc)
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)
180 { 194 {
181 err = ZIP_ERRNO; 195 err = ZIP_ERRNO;
182 } 196 }
183 197
184 if (err == ZIP_OK) 198 if (err == ZIP_OK)
185 do 199 do
186 { 200 {
(...skipping 17 matching lines...) Expand all
204 218
205 *result_crc=calculate_crc; 219 *result_crc=calculate_crc;
206 printf("file %s crc %lx\n", filenameinzip, calculate_crc); 220 printf("file %s crc %lx\n", filenameinzip, calculate_crc);
207 return err; 221 return err;
208 } 222 }
209 223
210 int isLargeFile(const char* filename) 224 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
224 if(pos >= 0xffffffff) 237 if(pos >= 0xffffffff)
225 largeFile = 1; 238 largeFile = 1;
226 239
227 fclose(pFile); 240 fclose(pFile);
228 } 241 }
229 242
230 return largeFile; 243 return largeFile;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 (opt_compress_level != 0) ? Z_DEFLATED : 0, 453 (opt_compress_level != 0) ? Z_DEFLATED : 0,
441 opt_compress_level,0, 454 opt_compress_level,0,
442 /* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEG Y, */ 455 /* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEG Y, */
443 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, 456 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
444 password,crcFile, zip64); 457 password,crcFile, zip64);
445 458
446 if (err != ZIP_OK) 459 if (err != ZIP_OK)
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;
454 printf("error in opening %s for reading\n",filenameinzip ); 467 printf("error in opening %s for reading\n",filenameinzip );
455 } 468 }
456 } 469 }
457 470
458 if (err == ZIP_OK) 471 if (err == ZIP_OK)
459 do 472 do
460 { 473 {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 printf("error in closing %s\n",filename_try); 511 printf("error in closing %s\n",filename_try);
499 } 512 }
500 else 513 else
501 { 514 {
502 do_help(); 515 do_help();
503 } 516 }
504 517
505 free(buf); 518 free(buf);
506 return 0; 519 return 0;
507 } 520 }
OLDNEW
« no previous file with comments | « third_party/zlib/contrib/minizip/miniunz.c ('k') | third_party/zlib/contrib/minizip/mztools.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698