Return-Path: X-Original-To: apmail-corinthia-commits-archive@minotaur.apache.org Delivered-To: apmail-corinthia-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8C8A9104A4 for ; Thu, 1 Jan 2015 12:07:59 +0000 (UTC) Received: (qmail 60122 invoked by uid 500); 1 Jan 2015 12:07:57 -0000 Delivered-To: apmail-corinthia-commits-archive@corinthia.apache.org Received: (qmail 60104 invoked by uid 500); 1 Jan 2015 12:07:57 -0000 Mailing-List: contact commits-help@corinthia.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@corinthia.incubator.apache.org Delivered-To: mailing list commits@corinthia.incubator.apache.org Received: (qmail 60095 invoked by uid 99); 1 Jan 2015 12:07:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Jan 2015 12:07:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 01 Jan 2015 12:07:56 +0000 Received: (qmail 60065 invoked by uid 99); 1 Jan 2015 12:07:36 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Jan 2015 12:07:36 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 027E0A3BC5C; Thu, 1 Jan 2015 12:07:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jani@apache.org To: commits@corinthia.incubator.apache.org Date: Thu, 01 Jan 2015 12:07:36 -0000 Message-Id: <01a1bae30e5b408ab067c92eb6fdee20@git.apache.org> In-Reply-To: <7d278435d44a43d8a65299eb9c7283b3@git.apache.org> References: <7d278435d44a43d8a65299eb9c7283b3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] incubator-corinthia git commit: integrated multi zip API in DFZipFile.c X-Virus-Checked: Checked by ClamAV on apache.org integrated multi zip API in DFZipFile.c Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/b159258c Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/b159258c Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/b159258c Branch: refs/heads/RTC_platform Commit: b159258cf88994b497c610894129d1a3cdd68436 Parents: 1a3eaeb Author: jani Authored: Thu Jan 1 13:06:21 2015 +0100 Committer: jani Committed: Thu Jan 1 13:06:21 2015 +0100 ---------------------------------------------------------------------- DocFormats/core/src/lib/DFZipFile.c | 29 ++++++++++++++++------------- DocFormats/platform/src/Wrapper.c | 4 ++-- 2 files changed, 18 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/b159258c/DocFormats/core/src/lib/DFZipFile.c ---------------------------------------------------------------------- diff --git a/DocFormats/core/src/lib/DFZipFile.c b/DocFormats/core/src/lib/DFZipFile.c index 8d54522..73b3fef 100644 --- a/DocFormats/core/src/lib/DFZipFile.c +++ b/DocFormats/core/src/lib/DFZipFile.c @@ -35,24 +35,26 @@ static int zipError(DFError **error, const char *format, ...) int DFUnzip(const char *zipFilename, DFStorage *storage, DFError **error) { char entryName[4096]; + int zipId; - if (DFextZipOpen(zipFilename, 1) <= 0) - return zipError(error,"Cannot open file"); + zipId = DFextZipOpen(zipFilename, 1); + if (zipId < 0) + return zipError(error,"Cannot open file"); int ret; - for (; (ret = DFextZipOpenNextFile(entryName, sizeof(entryName))) > 0;) { + for (; (ret = DFextZipOpenNextFile(zipId, entryName, sizeof(entryName))) > 0;) { DFBuffer *content = DFBufferNew(); unsigned char buf[4096]; int r; - while (0 < (r = DFextZipReadCurrentFile(buf, sizeof(buf)))) + while (0 < (r = DFextZipReadCurrentFile(zipId, buf, sizeof(buf)))) DFBufferAppendData(content,(void *)buf,r); if (0 > r) { DFBufferRelease(content); return zipError(error,"%s: decompression failed",entryName); } - if (DFextZipCloseFile() < 0) { + if (DFextZipCloseFile(zipId) < 0) { DFBufferRelease(content); return zipError(error,"%s: decompression failed",entryName); } @@ -67,20 +69,20 @@ int DFUnzip(const char *zipFilename, DFStorage *storage, DFError **error) if (ret < 0) return zipError(error,"Zip directory is corrupt"); - DFextZipClose(); + DFextZipClose(zipId); return 1; } -static int zipAddFile(const char *dest, DFBuffer *content, DFError **error) +static int zipAddFile(int zipId, const char *dest, DFBuffer *content, DFError **error) { - if (DFextZipOpenNextFile(dest, 0) < 0) + if (DFextZipOpenNextFile(zipId, dest, 0) < 0) return zipError(error,"%s: Cannot create entry in zip file",dest); - if (DFextZipWriteCurrentFile(content->data,(unsigned int)content->len) < 0) + if (DFextZipWriteCurrentFile(zipId, content->data, (unsigned int)content->len) < 0) return zipError(error,"%s: Error writing to entry in zip file",dest); - if (DFextZipCloseFile() <0) + if (DFextZipCloseFile(zipId) <0) return zipError(error,"%s: Error closing entry in zip file",dest); return 1; } @@ -92,9 +94,10 @@ int DFZip(const char *zipFilename, DFStorage *storage, DFError **error) const char **allPaths = NULL; DFBuffer *content = NULL; int ok = 0; + int zipId; allPaths = DFStorageList(storage,error); - if (allPaths == NULL || DFextZipOpen(zipFilename, 0) <= 0) + if (allPaths == NULL || (zipId = DFextZipOpen(zipFilename, 0)) < 0) { DFErrorFormat(error,"Cannot create file"); } @@ -110,7 +113,7 @@ int DFZip(const char *zipFilename, DFStorage *storage, DFError **error) goto end; } - if (!zipAddFile(path,content,error)) + if (!zipAddFile(zipId, path, content, error)) goto end; } @@ -120,6 +123,6 @@ int DFZip(const char *zipFilename, DFStorage *storage, DFError **error) end: DFBufferRelease(content); free(allPaths); - DFextZipClose(); + DFextZipClose(zipId); return ok; } http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/b159258c/DocFormats/platform/src/Wrapper.c ---------------------------------------------------------------------- diff --git a/DocFormats/platform/src/Wrapper.c b/DocFormats/platform/src/Wrapper.c index fe48a49..49a4121 100644 --- a/DocFormats/platform/src/Wrapper.c +++ b/DocFormats/platform/src/Wrapper.c @@ -29,7 +29,7 @@ int DFextZipOpen(const char *zipFilename, int doUnzip) { int zipId; // find an empty slot - for (zipId = 0; zipId < MAX_ZIP_OPEN && myZipStorage[i].myZipFile; ++i) ; + for (zipId = 0; zipId < MAX_ZIP_OPEN && myZipStorage[zipId].myZipFile; ++zipId) ; if (zipId >= MAX_ZIP_OPEN) return -1; @@ -89,7 +89,7 @@ int DFextZipOpenNextFile(int zipId, char *entryName, const int maxName) // check for prefix "/" and if present skip file if (entryName[strlen(entryName) - 1] == '/') - return DFextZipOpenNextFile(entryName, maxName); + return DFextZipOpenNextFile(zipId, entryName, maxName); // open Regular file if (unzOpenCurrentFile(myZipStorage[zipId].myZipFile) != UNZ_OK)