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

Side by Side Diff: third_party/zlib/contrib/minizip/minizip.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/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 #if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) 16 #ifndef _WIN32
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
44 #include <stdio.h> 31 #include <stdio.h>
45 #include <stdlib.h> 32 #include <stdlib.h>
46 #include <string.h> 33 #include <string.h>
47 #include <time.h> 34 #include <time.h>
48 #include <errno.h> 35 #include <errno.h>
49 #include <fcntl.h> 36 #include <fcntl.h>
50 37
51 #ifdef _WIN32 38 #ifdef unix
52 # include <direct.h>
53 # include <io.h>
54 #else
55 # include <unistd.h> 39 # include <unistd.h>
56 # include <utime.h> 40 # include <utime.h>
57 # include <sys/types.h> 41 # include <sys/types.h>
58 # include <sys/stat.h> 42 # include <sys/stat.h>
43 #else
44 # include <direct.h>
45 # include <io.h>
59 #endif 46 #endif
60 47
61 #include "zip.h" 48 #include "zip.h"
62 49
63 #ifdef _WIN32 50 #ifdef _WIN32
64 #define USEWIN32IOAPI 51 #define USEWIN32IOAPI
65 #include "iowin32.h" 52 #include "iowin32.h"
66 #endif 53 #endif
67 54
68 55
(...skipping 18 matching lines...) Expand all
87 { 74 {
88 FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal); 75 FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal);
89 FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0); 76 FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0);
90 FindClose(hFind); 77 FindClose(hFind);
91 ret = 1; 78 ret = 1;
92 } 79 }
93 } 80 }
94 return ret; 81 return ret;
95 } 82 }
96 #else 83 #else
97 #ifdef unix || __APPLE__ 84 #ifdef unix
98 uLong filetime(f, tmzip, dt) 85 uLong filetime(f, tmzip, dt)
99 char *f; /* name of file to get info on */ 86 char *f; /* name of file to get info on */
100 tm_zip *tmzip; /* return value: access, modific. and creation times */ 87 tm_zip *tmzip; /* return value: access, modific. and creation times */
101 uLong *dt; /* dostime */ 88 uLong *dt; /* dostime */
102 { 89 {
103 int ret=0; 90 int ret=0;
104 struct stat s; /* results of stat() */ 91 struct stat s; /* results of stat() */
105 struct tm* filedate; 92 struct tm* filedate;
106 time_t tm_t=0; 93 time_t tm_t=0;
107 94
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 #endif 135 #endif
149 136
150 137
151 138
152 139
153 int check_exist_file(filename) 140 int check_exist_file(filename)
154 const char* filename; 141 const char* filename;
155 { 142 {
156 FILE* ftestexist; 143 FILE* ftestexist;
157 int ret = 1; 144 int ret = 1;
158 ftestexist = FOPEN_FUNC(filename,"rb"); 145 ftestexist = fopen64(filename,"rb");
159 if (ftestexist==NULL) 146 if (ftestexist==NULL)
160 ret = 0; 147 ret = 0;
161 else 148 else
162 fclose(ftestexist); 149 fclose(ftestexist);
163 return ret; 150 return ret;
164 } 151 }
165 152
166 void do_banner() 153 void do_banner()
167 { 154 {
168 printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vol lant\n"); 155 printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vol lant\n");
(...skipping 10 matching lines...) Expand all
179 " -9 Compress better\n\n" \ 166 " -9 Compress better\n\n" \
180 " -j exclude path. store only the file name.\n\n"); 167 " -j exclude path. store only the file name.\n\n");
181 } 168 }
182 169
183 /* calculate the CRC32 of a file, 170 /* calculate the CRC32 of a file,
184 because to encrypt a file, we need known the CRC32 of the file before */ 171 because to encrypt a file, we need known the CRC32 of the file before */
185 int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne d long* result_crc) 172 int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne d long* result_crc)
186 { 173 {
187 unsigned long calculate_crc=0; 174 unsigned long calculate_crc=0;
188 int err=ZIP_OK; 175 int err=ZIP_OK;
189 FILE * fin = FOPEN_FUNC(filenameinzip,"rb"); 176 FILE * fin = fopen64(filenameinzip,"rb");
190
191 unsigned long size_read = 0; 177 unsigned long size_read = 0;
192 unsigned long total_read = 0; 178 unsigned long total_read = 0;
193 if (fin==NULL) 179 if (fin==NULL)
194 { 180 {
195 err = ZIP_ERRNO; 181 err = ZIP_ERRNO;
196 } 182 }
197 183
198 if (err == ZIP_OK) 184 if (err == ZIP_OK)
199 do 185 do
200 { 186 {
(...skipping 17 matching lines...) Expand all
218 204
219 *result_crc=calculate_crc; 205 *result_crc=calculate_crc;
220 printf("file %s crc %lx\n", filenameinzip, calculate_crc); 206 printf("file %s crc %lx\n", filenameinzip, calculate_crc);
221 return err; 207 return err;
222 } 208 }
223 209
224 int isLargeFile(const char* filename) 210 int isLargeFile(const char* filename)
225 { 211 {
226 int largeFile = 0; 212 int largeFile = 0;
227 ZPOS64_T pos = 0; 213 ZPOS64_T pos = 0;
228 FILE* pFile = FOPEN_FUNC(filename, "rb"); 214 FILE* pFile = fopen64(filename, "rb");
229 215
230 if(pFile != NULL) 216 if(pFile != NULL)
231 { 217 {
232 int n = FSEEKO_FUNC(pFile, 0, SEEK_END); 218 int n = fseeko64(pFile, 0, SEEK_END);
233 pos = FTELLO_FUNC(pFile); 219
220 pos = ftello64(pFile);
234 221
235 printf("File : %s is %lld bytes\n", filename, pos); 222 printf("File : %s is %lld bytes\n", filename, pos);
236 223
237 if(pos >= 0xffffffff) 224 if(pos >= 0xffffffff)
238 largeFile = 1; 225 largeFile = 1;
239 226
240 fclose(pFile); 227 fclose(pFile);
241 } 228 }
242 229
243 return largeFile; 230 return largeFile;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 (opt_compress_level != 0) ? Z_DEFLATED : 0, 440 (opt_compress_level != 0) ? Z_DEFLATED : 0,
454 opt_compress_level,0, 441 opt_compress_level,0,
455 /* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEG Y, */ 442 /* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEG Y, */
456 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, 443 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
457 password,crcFile, zip64); 444 password,crcFile, zip64);
458 445
459 if (err != ZIP_OK) 446 if (err != ZIP_OK)
460 printf("error in opening %s in zipfile\n",filenameinzip); 447 printf("error in opening %s in zipfile\n",filenameinzip);
461 else 448 else
462 { 449 {
463 fin = FOPEN_FUNC(filenameinzip,"rb"); 450 fin = fopen64(filenameinzip,"rb");
464 if (fin==NULL) 451 if (fin==NULL)
465 { 452 {
466 err=ZIP_ERRNO; 453 err=ZIP_ERRNO;
467 printf("error in opening %s for reading\n",filenameinzip ); 454 printf("error in opening %s for reading\n",filenameinzip );
468 } 455 }
469 } 456 }
470 457
471 if (err == ZIP_OK) 458 if (err == ZIP_OK)
472 do 459 do
473 { 460 {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 printf("error in closing %s\n",filename_try); 498 printf("error in closing %s\n",filename_try);
512 } 499 }
513 else 500 else
514 { 501 {
515 do_help(); 502 do_help();
516 } 503 }
517 504
518 free(buf); 505 free(buf);
519 return 0; 506 return 0;
520 } 507 }
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