You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by ja...@apache.org on 2015/01/01 11:10:26 UTC

[04/19] incubator-corinthia git commit: work

work


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/783e6f7d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/783e6f7d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/783e6f7d

Branch: refs/heads/RTC_platform
Commit: 783e6f7d41fc547d8d13c93db58e769b6fd0b6ec
Parents: 8c2b64a
Author: jani <ja...@apache.org>
Authored: Sun Dec 28 12:42:44 2014 +0100
Committer: jani <ja...@apache.org>
Committed: Sun Dec 28 12:42:44 2014 +0100

----------------------------------------------------------------------
 DocFormats/core/src/lib/DFZipFile.c      | 56 ++++++++++++---------------
 DocFormats/platform/headers/DFPlatform.h |  8 ++--
 2 files changed, 30 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/783e6f7d/DocFormats/core/src/lib/DFZipFile.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFZipFile.c b/DocFormats/core/src/lib/DFZipFile.c
index 60b810a..56da721 100644
--- a/DocFormats/core/src/lib/DFZipFile.c
+++ b/DocFormats/core/src/lib/DFZipFile.c
@@ -34,9 +34,8 @@ static int zipError(DFError **error, const char *format, ...)
 
 int DFUnzip(const char *zipFilename, DFStorage *storage, DFError **error)
 {
-    unzFile zipFile = unzOpen(zipFilename);
-    if (zipFile == NULL)
-        return zipError(error,"Cannot open file");
+  if (DFextZipOpen(zipFilename, 1) <= 0)
+    return zipError(error,"Cannot open file");
 
     int ret;
     for (ret = unzGoToFirstFile(zipFile); ret == UNZ_OK; ret = unzGoToNextFile(zipFile)) {
@@ -77,8 +76,7 @@ int DFUnzip(const char *zipFilename, DFStorage *storage, DFError **error)
     if (UNZ_END_OF_LIST_OF_FILE != ret)
         return zipError(error,"Zip directory is corrupt");
 
-    if (UNZ_OK != unzClose(zipFile))
-        return zipError(error,"Cannot close file");
+    DFextZipClose();
 
     return 1;
 }
@@ -112,40 +110,36 @@ static int zipAddFile(zipFile zip, const char *dest, DFBuffer *content, DFError
 int DFZip(const char *zipFilename, DFStorage *storage, DFError **error)
 {
     const char **allPaths = NULL;
-    zipFile zip = NULL;
     DFBuffer *content = NULL;
     int ok = 0;
 
     allPaths = DFStorageList(storage,error);
-    if (allPaths == NULL)
-        goto end;
-
-    zip = zipOpen(zipFilename,APPEND_STATUS_CREATE);
-    if (zip == NULL) {
-        DFErrorFormat(error,"Cannot create file");
-        goto end;
+    if (allPaths == NULL || DFextZipOpen(zipFilename, 0) <= 0)
+    {
+      DFErrorFormat(error,"Cannot create file");
+      goto end;
     }
-
-    for (int i = 0; allPaths[i]; i++) {
-        const char *path = allPaths[i];
-
-        DFBufferRelease(content);
-        content = DFBufferReadFromStorage(storage,path,error);
-        if (content == NULL) {
-            DFErrorFormat(error,"%s: %s",path,DFErrorMessage(error));
-            goto end;
-        }
-
-        if (!zipAddFile(zip,path,content,error))
-            goto end;
+    else
+    {
+      for (int i = 0; allPaths[i]; i++) {
+          const char *path = allPaths[i];
+
+          DFBufferRelease(content);
+          content = DFBufferReadFromStorage(storage,path,error);
+          if (content == NULL) {
+              DFErrorFormat(error,"%s: %s",path,DFErrorMessage(error));
+              goto end;
+          }
+
+          if (!zipAddFile(zip,path,content,error))
+              goto end;
+      }
+
+      ok = 1;
     }
 
-    ok = 1;
-
-end:
     DFBufferRelease(content);
     free(allPaths);
-    if ((zip != NULL) && (ZIP_OK != zipClose(zip,NULL)))
-        return zipError(error,"Cannot close file");
+    DFextZipClose();
     return ok;
 }

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/783e6f7d/DocFormats/platform/headers/DFPlatform.h
----------------------------------------------------------------------
diff --git a/DocFormats/platform/headers/DFPlatform.h b/DocFormats/platform/headers/DFPlatform.h
index 577fcff..8ce3281 100755
--- a/DocFormats/platform/headers/DFPlatform.h
+++ b/DocFormats/platform/headers/DFPlatform.h
@@ -35,9 +35,11 @@ typedef void (*DFOnceFunction)(void);
 void DFInitOnce(DFOnce *once, DFOnceFunction fun);
 
 // Zip functions
-int DFextZipOpenRead(const char *zipFilename);
-int DFextZipOpenCreate(const char *zipFilename);
+int  DFextZipOpen(const char *zipFilename, int doUnzip);
+void DFextZipClose(void);
+
+
+
 int DFextZipOpenNextFile(const char *zipFile, char *entryName, const int maxName);
 int DFextZipReadCurrentFile(char *buf, const int maxLen);
-int DFextZipClose(void);
 #endif