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

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

Issue 8873039: Add an API to unpack Zip files directly from and to file descriptors. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
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 unified diff | Download patch
OLDNEW
1 /* ioapi.c -- IO base function header for compress/uncompress .zip 1 /* ioapi.c -- IO base function header for compress/uncompress .zip
2 files using zlib + zip or unzip API 2 files using zlib + zip or unzip API
3 3
4 Version 1.01e, February 12th, 2005 4 Version 1.01e, February 12th, 2005
5 5
6 Copyright (C) 1998-2005 Gilles Vollant 6 Copyright (C) 1998-2005 Gilles Vollant
7 */ 7 */
8 8
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 mode_fopen = "r+b"; 82 mode_fopen = "r+b";
83 else 83 else
84 if (mode & ZLIB_FILEFUNC_MODE_CREATE) 84 if (mode & ZLIB_FILEFUNC_MODE_CREATE)
85 mode_fopen = "wb"; 85 mode_fopen = "wb";
86 86
87 if ((filename!=NULL) && (mode_fopen != NULL)) 87 if ((filename!=NULL) && (mode_fopen != NULL))
88 file = fopen(filename, mode_fopen); 88 file = fopen(filename, mode_fopen);
89 return file; 89 return file;
90 } 90 }
91 91
92 // Google
93 voidpf ZCALLBACK fdopen_file_func (opaque, filename, mode)
94 voidpf opaque;
95 const char* filename;
96 int mode;
97 {
98 FILE* file = NULL;
99 const char* mode_fopen = NULL;
100 if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
101 mode_fopen = "rb";
102 else
103 if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
104 mode_fopen = "r+b";
105 else
106 if (mode & ZLIB_FILEFUNC_MODE_CREATE)
107 mode_fopen = "wb";
108
109 if ((filename!=NULL) && (mode_fopen != NULL))
110 file = fdopen(*(int*)opaque, mode_fopen);
111 return file;
112 }
113
92 114
93 uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) 115 uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
94 voidpf opaque; 116 voidpf opaque;
95 voidpf stream; 117 voidpf stream;
96 void* buf; 118 void* buf;
97 uLong size; 119 uLong size;
98 { 120 {
99 uLong ret; 121 uLong ret;
100 ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); 122 ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
101 return ret; 123 return ret;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 { 193 {
172 pzlib_filefunc_def->zopen_file = fopen_file_func; 194 pzlib_filefunc_def->zopen_file = fopen_file_func;
173 pzlib_filefunc_def->zread_file = fread_file_func; 195 pzlib_filefunc_def->zread_file = fread_file_func;
174 pzlib_filefunc_def->zwrite_file = fwrite_file_func; 196 pzlib_filefunc_def->zwrite_file = fwrite_file_func;
175 pzlib_filefunc_def->ztell_file = ftell_file_func; 197 pzlib_filefunc_def->ztell_file = ftell_file_func;
176 pzlib_filefunc_def->zseek_file = fseek_file_func; 198 pzlib_filefunc_def->zseek_file = fseek_file_func;
177 pzlib_filefunc_def->zclose_file = fclose_file_func; 199 pzlib_filefunc_def->zclose_file = fclose_file_func;
178 pzlib_filefunc_def->zerror_file = ferror_file_func; 200 pzlib_filefunc_def->zerror_file = ferror_file_func;
179 pzlib_filefunc_def->opaque = NULL; 201 pzlib_filefunc_def->opaque = NULL;
180 } 202 }
203
204 // Google
205 void fill_fdopen_filefunc (pzlib_filefunc_def, fd)
206 zlib_filefunc_def* pzlib_filefunc_def;
207 const int fd;
208 {
209 fill_fopen_filefunc(pzlib_filefunc_def);
210 pzlib_filefunc_def->zopen_file = fdopen_file_func;
211 int *ptr_fd = malloc(sizeof(int));
212 *ptr_fd = fd;
213 pzlib_filefunc_def->opaque = ptr_fd;
214 }
OLDNEW
« chrome/common/zip_reader_unittest.cc ('K') | « third_party/zlib/contrib/minizip/ioapi.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698