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

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: 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 3aad38a72259c5aba33f6a6001eead03918619aa..3a1f5d6fb7a3ad5473cb79e87dbd95511f0030df 100644
--- a/third_party/zlib/contrib/minizip/ioapi.c
+++ b/third_party/zlib/contrib/minizip/ioapi.c
@@ -89,6 +89,28 @@ voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
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;
+}
+
uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
voidpf opaque;
@@ -178,3 +200,15 @@ void fill_fopen_filefunc (pzlib_filefunc_def)
pzlib_filefunc_def->zerror_file = ferror_file_func;
pzlib_filefunc_def->opaque = NULL;
}
+
+// Google
+void fill_fdopen_filefunc (pzlib_filefunc_def, fd)
+ zlib_filefunc_def* pzlib_filefunc_def;
+ const 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