diff options
author | Doug Zongker <dougz@android.com> | 2010-02-01 23:40:12 +0100 |
---|---|---|
committer | Doug Zongker <dougz@android.com> | 2010-02-01 23:40:12 +0100 |
commit | 6aece33b3f3af6a161e326af36bc894427fcf5ad (patch) | |
tree | b164457ed1f664a0d195f30933b70386687a0887 /minzip/Zip.c | |
parent | fix parsing of dumpkeys output (diff) | |
download | android_bootable_recovery-6aece33b3f3af6a161e326af36bc894427fcf5ad.tar android_bootable_recovery-6aece33b3f3af6a161e326af36bc894427fcf5ad.tar.gz android_bootable_recovery-6aece33b3f3af6a161e326af36bc894427fcf5ad.tar.bz2 android_bootable_recovery-6aece33b3f3af6a161e326af36bc894427fcf5ad.tar.lz android_bootable_recovery-6aece33b3f3af6a161e326af36bc894427fcf5ad.tar.xz android_bootable_recovery-6aece33b3f3af6a161e326af36bc894427fcf5ad.tar.zst android_bootable_recovery-6aece33b3f3af6a161e326af36bc894427fcf5ad.zip |
Diffstat (limited to '')
-rw-r--r-- | minzip/Zip.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/minzip/Zip.c b/minzip/Zip.c index 8cdb89874..46d2f829e 100644 --- a/minzip/Zip.c +++ b/minzip/Zip.c @@ -810,6 +810,43 @@ bool mzExtractZipEntryToFile(const ZipArchive *pArchive, return true; } +typedef struct { + unsigned char* buffer; + long len; +} BufferExtractCookie; + +static bool bufferProcessFunction(const unsigned char *data, int dataLen, + void *cookie) { + BufferExtractCookie *bec = (BufferExtractCookie*)cookie; + + memmove(bec->buffer, data, dataLen); + bec->buffer += dataLen; + bec->len -= dataLen; + + return true; +} + +/* + * Uncompress "pEntry" in "pArchive" to buffer, which must be large + * enough to hold mzGetZipEntryUncomplen(pEntry) bytes. + */ +bool mzExtractZipEntryToBuffer(const ZipArchive *pArchive, + const ZipEntry *pEntry, unsigned char *buffer) +{ + BufferExtractCookie bec; + bec.buffer = buffer; + bec.len = mzGetZipEntryUncompLen(pEntry); + + bool ret = mzProcessZipEntryContents(pArchive, pEntry, + bufferProcessFunction, (void*)&bec); + if (!ret || bec.len != 0) { + LOGE("Can't extract entry to memory buffer.\n"); + return false; + } + return true; +} + + /* Helper state to make path translation easier and less malloc-happy. */ typedef struct { |