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

Unified Diff: third_party/zlib/contrib/minizip/miniunz.c

Issue 8806004: Update zlib to 1.2.5. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/zlib/contrib/minizip/miniunz.c
===================================================================
--- third_party/zlib/contrib/minizip/miniunz.c (revision 113739)
+++ third_party/zlib/contrib/minizip/miniunz.c (working copy)
@@ -1,10 +1,31 @@
/*
miniunz.c
- Version 1.01e, February 12th, 2005
+ Version 1.1, February 14h, 2010
+ sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
- Copyright (C) 1998-2005 Gilles Vollant
+ Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+ Modifications of Unzip for Zip64
+ Copyright (C) 2007-2008 Even Rouault
+
+ Modifications for Zip64 support on both zip and unzip
+ Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
*/
+#ifndef _WIN32
+ #ifndef __USE_FILE_OFFSET64
+ #define __USE_FILE_OFFSET64
+ #endif
+ #ifndef __USE_LARGEFILE64
+ #define __USE_LARGEFILE64
+ #endif
+ #ifndef _LARGEFILE64_SOURCE
+ #define _LARGEFILE64_SOURCE
+ #endif
+ #ifndef _FILE_OFFSET_BIT
+ #define _FILE_OFFSET_BIT 64
+ #endif
+#endif
#include <stdio.h>
#include <stdlib.h>
@@ -27,7 +48,7 @@
#define WRITEBUFFERSIZE (8192)
#define MAXFILENAME (256)
-#ifdef WIN32
+#ifdef _WIN32
#define USEWIN32IOAPI
#include "iowin32.h"
#endif
@@ -51,11 +72,11 @@
uLong dosdate;
tm_unz tmu_date;
{
-#ifdef WIN32
+#ifdef _WIN32
HANDLE hFile;
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
- hFile = CreateFile(filename,GENERIC_READ | GENERIC_WRITE,
+ hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE,
0,NULL,OPEN_EXISTING,0,NULL);
GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
@@ -91,8 +112,8 @@
const char* dirname;
{
int ret=0;
-#ifdef WIN32
- ret = mkdir(dirname);
+#ifdef _WIN32
+ ret = _mkdir(dirname);
#else
#ifdef unix
ret = mkdir (dirname,0775);
@@ -112,6 +133,11 @@
return 0;
buffer = (char*)malloc(len+1);
+ if (buffer==NULL)
+ {
+ printf("Error allocating memory\n");
+ return UNZ_INTERNALERROR;
+ }
strcpy(buffer,newdir);
if (buffer[len-1] == '/') {
@@ -164,34 +190,61 @@
" -p extract crypted file using password\n\n");
}
+void Display64BitsSize(ZPOS64_T n, int size_char)
+{
+ /* to avoid compatibility problem , we do here the conversion */
+ char number[21];
+ int offset=19;
+ int pos_string = 19;
+ number[20]=0;
+ for (;;) {
+ number[offset]=(char)((n%10)+'0');
+ if (number[offset] != '0')
+ pos_string=offset;
+ n/=10;
+ if (offset==0)
+ break;
+ offset--;
+ }
+ {
+ int size_display_string = 19-pos_string;
+ while (size_char > size_display_string)
+ {
+ size_char--;
+ printf(" ");
+ }
+ }
+ printf("%s",&number[pos_string]);
+}
+
int do_list(uf)
unzFile uf;
{
uLong i;
- unz_global_info gi;
+ unz_global_info64 gi;
int err;
- err = unzGetGlobalInfo (uf,&gi);
+ err = unzGetGlobalInfo64(uf,&gi);
if (err!=UNZ_OK)
printf("error %d with zipfile in unzGetGlobalInfo \n",err);
- printf(" Length Method Size Ratio Date Time CRC-32 Name\n");
- printf(" ------ ------ ---- ----- ---- ---- ------ ----\n");
+ printf(" Length Method Size Ratio Date Time CRC-32 Name\n");
+ printf(" ------ ------ ---- ----- ---- ---- ------ ----\n");
for (i=0;i<gi.number_entry;i++)
{
char filename_inzip[256];
- unz_file_info file_info;
+ unz_file_info64 file_info;
uLong ratio=0;
const char *string_method;
char charCrypt=' ';
- err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
+ err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
if (err!=UNZ_OK)
{
printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
break;
}
if (file_info.uncompressed_size>0)
- ratio = (file_info.compressed_size*100)/file_info.uncompressed_size;
+ ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size);
/* display a '*' if the file is crypted */
if ((file_info.flag & 1) != 0)
@@ -211,12 +264,17 @@
string_method="Defl:F"; /* 2:fast , 3 : extra fast*/
}
else
+ if (file_info.compression_method==Z_BZIP2ED)
+ {
+ string_method="BZip2 ";
+ }
+ else
string_method="Unkn. ";
- printf("%7lu %6s%c%7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n",
- file_info.uncompressed_size,string_method,
- charCrypt,
- file_info.compressed_size,
+ Display64BitsSize(file_info.uncompressed_size,7);
+ printf(" %6s%c",string_method,charCrypt);
+ Display64BitsSize(file_info.compressed_size,7);
+ printf(" %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n",
ratio,
(uLong)file_info.tmu_date.tm_mon + 1,
(uLong)file_info.tmu_date.tm_mday,
@@ -252,9 +310,9 @@
void* buf;
uInt size_buf;
- unz_file_info file_info;
+ unz_file_info64 file_info;
uLong ratio=0;
- err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
+ err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
if (err!=UNZ_OK)
{
@@ -306,7 +364,7 @@
{
char rep=0;
FILE* ftestexist;
- ftestexist = fopen(write_filename,"rb");
+ ftestexist = fopen64(write_filename,"rb");
if (ftestexist!=NULL)
{
fclose(ftestexist);
@@ -317,7 +375,7 @@
printf("The file %s exists. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
ret = scanf("%1s",answer);
- if (ret != 1)
+ if (ret != 1)
{
exit(EXIT_FAILURE);
}
@@ -337,7 +395,7 @@
if ((skip==0) && (err==UNZ_OK))
{
- fout=fopen(write_filename,"wb");
+ fout=fopen64(write_filename,"wb");
/* some zipfile don't contain directory alone before file */
if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
@@ -347,7 +405,7 @@
*(filename_withoutpath-1)='\0';
makedir(write_filename);
*(filename_withoutpath-1)=c;
- fout=fopen(write_filename,"wb");
+ fout=fopen64(write_filename,"wb");
}
if (fout==NULL)
@@ -409,11 +467,11 @@
const char* password;
{
uLong i;
- unz_global_info gi;
+ unz_global_info64 gi;
int err;
FILE* fout=NULL;
- err = unzGetGlobalInfo (uf,&gi);
+ err = unzGetGlobalInfo64(uf,&gi);
if (err!=UNZ_OK)
printf("error %d with zipfile in unzGetGlobalInfo \n",err);
@@ -470,6 +528,7 @@
const char *password=NULL;
char filename_try[MAXFILENAME+16] = "";
int i;
+ int ret_value=0;
int opt_do_list=0;
int opt_do_extract=1;
int opt_do_extract_withoutpath=0;
@@ -532,7 +591,7 @@
{
# ifdef USEWIN32IOAPI
- zlib_filefunc_def ffunc;
+ zlib_filefunc64_def ffunc;
# endif
strncpy(filename_try, zipfilename,MAXFILENAME-1);
@@ -540,18 +599,18 @@
filename_try[ MAXFILENAME ] = '\0';
# ifdef USEWIN32IOAPI
- fill_win32_filefunc(&ffunc);
- uf = unzOpen2(zipfilename,&ffunc);
+ fill_win32_filefunc64A(&ffunc);
+ uf = unzOpen2_64(zipfilename,&ffunc);
# else
- uf = unzOpen(zipfilename);
+ uf = unzOpen64(zipfilename);
# endif
if (uf==NULL)
{
strcat(filename_try,".zip");
# ifdef USEWIN32IOAPI
- uf = unzOpen2(filename_try,&ffunc);
+ uf = unzOpen2_64(filename_try,&ffunc);
# else
- uf = unzOpen(filename_try);
+ uf = unzOpen64(filename_try);
# endif
}
}
@@ -564,22 +623,26 @@
printf("%s opened\n",filename_try);
if (opt_do_list==1)
- return do_list(uf);
+ ret_value = do_list(uf);
else if (opt_do_extract==1)
{
- if (opt_extractdir && chdir(dirname))
+#ifdef _WIN32
+ if (opt_extractdir && _chdir(dirname))
+#else
+ if (opt_extractdir && chdir(dirname))
+#endif
{
printf("Error changing into %s, aborting\n", dirname);
exit(-1);
}
if (filename_to_extract == NULL)
- return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,password);
+ ret_value = do_extract(uf, opt_do_extract_withoutpath, opt_overwrite, password);
else
- return do_extract_onefile(uf,filename_to_extract,
- opt_do_extract_withoutpath,opt_overwrite,password);
+ ret_value = do_extract_onefile(uf, filename_to_extract, opt_do_extract_withoutpath, opt_overwrite, password);
}
- unzCloseCurrentFile(uf);
- return 0;
+ unzClose(uf);
+
+ return ret_value;
}
« 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