minizip: added missing function for buffer load

This commit is contained in:
martell
2014-10-11 04:11:02 +01:00
parent ada4cee37a
commit a40f1dfb52
2 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
From 0a0d78034efbc45c103b1fbbb47343c48cdf6355 Mon Sep 17 00:00:00 2001
From: martell <martellmalone@gmail.com>
Date: Sat, 11 Oct 2014 03:32:38 +0100
Subject: [PATCH] unzip: add function unzOpenBuffer
---
Makefile.am | 1 +
unzip.c | 11 +++++++++++
unzip.h | 2 ++
3 files changed, 14 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index d83fee7..e2958e6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,7 @@ libminizip_la_SOURCES = \
ioapi.c \
unzip.c \
zip.c \
+ ioapi_mem.c \
${iowin32_src}
libminizip_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:0:0 -lz
diff --git a/unzip.c b/unzip.c
index ce02265..bb72a66 100644
--- a/unzip.c
+++ b/unzip.c
@@ -26,6 +26,7 @@
#include "zlib.h"
#include "unzip.h"
+#include "ioapi_mem.h"
#ifdef STDC
# include <stddef.h>
@@ -581,6 +582,16 @@ extern unzFile ZEXPORT unzOpen64(const void *path)
return unzOpenInternal(path, NULL, 1);
}
+extern unzFile ZEXPORT unzOpenBuffer(const void* buffer, uLong size)
+{
+ char path[48] = {0};
+ ourmemory_t FileMemory;
+ zlib_filefunc64_32_def memory_file;
+ sprintf(path, "%llx %lx", (unsigned long long)buffer, (unsigned long)size);
+ fill_memory_filefunc(&memory_file, &FileMemory);
+ return unzOpenInternal(path, &memory_file, 0);
+}
+
extern int ZEXPORT unzClose(unzFile file)
{
unz64_s* s;
diff --git a/unzip.h b/unzip.h
index 22c830f..28fedb9 100644
--- a/unzip.h
+++ b/unzip.h
@@ -143,6 +143,8 @@ extern unzFile ZEXPORT unzOpen64 OF((const void *path));
open64_file_func callback. Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char* does not describe the reality */
+extern unzFile ZEXPORT unzOpenBuffer OF((const void* buffer, uLong size));
+/* Open a Zip file, like unzOpen, but from a buffer */
extern unzFile ZEXPORT unzOpen2 OF((const char *path, zlib_filefunc_def* pzlib_filefunc_def));
/* Open a Zip file, like unzOpen, but provide a set of file low level API for read/write operations */
extern unzFile ZEXPORT unzOpen2_64 OF((const void *path, zlib_filefunc64_def* pzlib_filefunc_def));
--
2.1.2

View File

@@ -15,12 +15,14 @@ depends=("${MINGW_PACKAGE_PREFIX}-bzip2")
options=('staticlibs')
source=("http://zlib.net/current/${_realname}-${pkgver}.tar.gz"
"git://github.com/nmoinvaz/minizip.git"
"0001-unzip-add-function-unzOpenBuffer.patch"
01-zlib-1.2.7-1-buildsys.mingw.patch
02-no-undefined.mingw.patch
03-dont-put-sodir-into-L.mingw.patch
04-wrong-w8-check.mingw.patch
05-fix-a-typo.mingw.patch)
md5sums=('44d667c142d7cda120332623eab69f40'
'SKIP'
'SKIP'
'63affd37e371768c6adc6e6561e66daf'
'cf7e49f23103a7e42c2dee113ea29674'
@@ -41,6 +43,10 @@ prepare() {
rm -rf ${srcdir}/${_realname}-${pkgver}/contrib/minizip
cp -r ${srcdir}/minizip/ ${srcdir}/${_realname}-${pkgver}/contrib
cd ${srcdir}/${_realname}-${pkgver}/contrib/minizip
git am ${srcdir}/0001-unzip-add-function-unzOpenBuffer.patch
}
build() {