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

Unified 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: Lint fixes. 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
Index: third_party/zlib/contrib/minizip/ioapi.c
diff --git a/third_party/zlib/contrib/minizip/ioapi.c b/third_party/zlib/contrib/minizip/ioapi.c
index 49958f61ffd660c96031aa49dbcffd08b127ea45..94cf16a0f265fc096aa1a9dfef211e55bc9058f4 100644
--- a/third_party/zlib/contrib/minizip/ioapi.c
+++ b/third_party/zlib/contrib/minizip/ioapi.c
@@ -116,6 +116,28 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
return file;
}
+// Google
+voidpf ZCALLBACK fdopen_file_func (opaque, filename, mode)
+ voidpf opaque;
+ const char* filename;
+ int mode;
+{
+ FILE* file = NULL;
+ const char* mode_fopen = NULL;
+ if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
+ mode_fopen = "rb";
+ else
+ if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
+ mode_fopen = "r+b";
+ else
+ if (mode & ZLIB_FILEFUNC_MODE_CREATE)
+ mode_fopen = "wb";
+
+ if ((filename!=NULL) && (mode_fopen != NULL))
+ file = fdopen(*(int*)opaque, mode_fopen);
+ return file;
+}
+
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
{
@@ -233,3 +255,13 @@ void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
pzlib_filefunc_def->zerror_file = ferror_file_func;
pzlib_filefunc_def->opaque = NULL;
}
+
+// Google
+void fill_fdopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def, int fd)
+{
+ fill_fopen_filefunc(pzlib_filefunc_def);
+ pzlib_filefunc_def->zopen_file = fdopen_file_func;
+ int *ptr_fd = malloc(sizeof(int));
+ *ptr_fd = fd;
+ pzlib_filefunc_def->opaque = ptr_fd;
+}
« 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