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/07/29 22:20:26 UTC
[1/3] incubator-corinthia git commit: dfzip rename
Repository: incubator-corinthia
Updated Branches:
refs/heads/newZipExperiment [created] 1257d3f94
dfzip rename
remove doUnzip flag and renamed to DFZipOpen() and DFZipCreate()
Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/8462afc0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/8462afc0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/8462afc0
Branch: refs/heads/newZipExperiment
Commit: 8462afc04f0177fa62e173d85e55ce377bef3b1d
Parents: 6677e00
Author: jani <ja...@apache.org>
Authored: Tue Jul 28 17:59:53 2015 +0200
Committer: jani <ja...@apache.org>
Committed: Tue Jul 28 17:59:53 2015 +0200
----------------------------------------------------------------------
DocFormats/core/src/lib/DFZipFile.c | 4 ++--
DocFormats/headers/DFPlatform.h | 4 +++-
DocFormats/platform/src/Wrapper.c | 29 +++++++++++++++++++++++------
3 files changed, 28 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8462afc0/DocFormats/core/src/lib/DFZipFile.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFZipFile.c b/DocFormats/core/src/lib/DFZipFile.c
index ee5a648..2c17742 100644
--- a/DocFormats/core/src/lib/DFZipFile.c
+++ b/DocFormats/core/src/lib/DFZipFile.c
@@ -41,7 +41,7 @@ int DFUnzip(const char *zipFilename, DFStorage *storage, DFError **error)
char entryName[4096];
DFextZipHandleP zipHandle;
- zipHandle = DFextZipOpen(zipFilename, 1);
+ zipHandle = DFextZipOpen(zipFilename);
if (!zipHandle)
return zipError(error,"Cannot open file");
@@ -101,7 +101,7 @@ int DFZip(const char *zipFilename, DFStorage *storage, DFError **error)
DFextZipHandleP zipHandle = NULL;
allPaths = DFStorageList(storage,error);
- if (allPaths == NULL || !(zipHandle = DFextZipOpen(zipFilename, 0)))
+ if (allPaths == NULL || !(zipHandle = DFextZipCreate(zipFilename)))
{
DFErrorFormat(error,"Cannot create file");
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8462afc0/DocFormats/headers/DFPlatform.h
----------------------------------------------------------------------
diff --git a/DocFormats/headers/DFPlatform.h b/DocFormats/headers/DFPlatform.h
index 7f2e005..8e10fdb 100644
--- a/DocFormats/headers/DFPlatform.h
+++ b/DocFormats/headers/DFPlatform.h
@@ -77,7 +77,9 @@ typedef struct {
typedef DFextZipHandle * DFextZipHandleP;
-DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip);
+DFextZipHandleP DFextZipOpen(const char *zipFilename);
+
+DFextZipHandleP DFextZipCreate(const char *zipFilename);
int DFextZipClose(DFextZipHandleP zipHandle);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8462afc0/DocFormats/platform/src/Wrapper.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper.c b/DocFormats/platform/src/Wrapper.c
index 1e8e506..b9f37fe 100644
--- a/DocFormats/platform/src/Wrapper.c
+++ b/DocFormats/platform/src/Wrapper.c
@@ -23,7 +23,7 @@
#include "zip.h"
-DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip) {
+DFextZipHandleP DFextZipOpen(const char *zipFilename) {
DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
// no more memory
@@ -32,11 +32,8 @@ DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip) {
// Open file
zipHandle->zipFirst = 1;
- zipHandle->zipFlag = doUnzip;
- if (doUnzip)
- zipHandle->handle = unzOpen(zipFilename);
- else
- zipHandle->handle = zipOpen(zipFilename, APPEND_STATUS_CREATE);
+ zipHandle->zipFlag = 1;
+ zipHandle->handle = unzOpen(zipFilename);
if (zipHandle->handle)
return zipHandle;
@@ -47,6 +44,26 @@ DFextZipHandleP DFextZipOpen(const char *zipFilename, int doUnzip) {
+DFextZipHandleP DFextZipCreate(const char *zipFilename) {
+ DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
+
+ // no more memory
+ if (!zipHandle)
+ return NULL;
+
+ // Open file
+ zipHandle->zipFirst = 1;
+ zipHandle->zipFlag = 0;
+ zipHandle->handle = zipOpen(zipFilename, APPEND_STATUS_CREATE);
+
+ if (zipHandle->handle)
+ return zipHandle;
+
+ free(zipHandle);
+ return NULL;
+}
+
+
int DFextZipClose(DFextZipHandleP zipHandle)
{
int rc = 0;
[3/3] incubator-corinthia git commit: work
Posted by ja...@apache.org.
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/1257d3f9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/1257d3f9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/1257d3f9
Branch: refs/heads/newZipExperiment
Commit: 1257d3f945db748552a49f1166960d56b5713a7a
Parents: be6c3ce
Author: jani <ja...@apache.org>
Authored: Tue Jul 28 20:45:34 2015 +0200
Committer: jani <ja...@apache.org>
Committed: Tue Jul 28 20:45:34 2015 +0200
----------------------------------------------------------------------
DocFormats/headers/DFPlatform.h | 7 +-
DocFormats/platform/CMakeLists.txt | 3 +-
DocFormats/platform/src/Wrapper.c | 184 ---------------------
DocFormats/platform/src/Wrapper_zip.c | 250 +++++++++++++++++++++++++++++
4 files changed, 255 insertions(+), 189 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/1257d3f9/DocFormats/headers/DFPlatform.h
----------------------------------------------------------------------
diff --git a/DocFormats/headers/DFPlatform.h b/DocFormats/headers/DFPlatform.h
index d594779..f55ccc2 100644
--- a/DocFormats/headers/DFPlatform.h
+++ b/DocFormats/headers/DFPlatform.h
@@ -70,13 +70,12 @@ void DFInitOnce(DFOnce *once, DFOnceFunction fun);
// Zip functions
typedef struct {
- int x;
- } DFextZipHandle;
-
+ FILE *zip;
+} DFextZipHandle;
typedef DFextZipHandle * DFextZipHandleP;
-DFextZipHandleP DFextZipOpen(const char *zipFilename);
+DFextZipHandleP DFextZipOpen(const char *zipFilename);
DFextZipHandleP DFextZipCreate(const char *zipFilename);
int DFextZipClose(DFextZipHandleP zipHandle);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/1257d3f9/DocFormats/platform/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/DocFormats/platform/CMakeLists.txt b/DocFormats/platform/CMakeLists.txt
index f3ba68b..c31c031 100644
--- a/DocFormats/platform/CMakeLists.txt
+++ b/DocFormats/platform/CMakeLists.txt
@@ -93,7 +93,8 @@ set(GroupSrc
src/Linux.c
src/Unix.c
src/Win32.c
- src/Wrapper.c)
+ src/Wrapper.c
+ src/Wrapper_zip.c)
set(GroupTests
tests/OStests.c
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/1257d3f9/DocFormats/platform/src/Wrapper.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper.c b/DocFormats/platform/src/Wrapper.c
index 1ca4ef2..c397bf4 100644
--- a/DocFormats/platform/src/Wrapper.c
+++ b/DocFormats/platform/src/Wrapper.c
@@ -14,194 +14,10 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "DFPlatform.h"
-#include "unzip.h"
-#include "zip.h"
-
-
-DFextZipHandleP DFextZipOpen(const char *zipFilename) {
- DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
-#if 0
- // no more memory
- if (!zipHandle)
- return NULL;
-
- // Open file
- zipHandle->zipFirst = 1;
- zipHandle->handle = unzOpen(zipFilename);
-
- if (zipHandle->handle)
- return zipHandle;
-
- free(zipHandle);
-#endif
- return NULL;
-}
-
-
-
-DFextZipHandleP OLD_DFextZipOpen(const char *zipFilename) {
- DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
-
-#if 0
- // no more memory
- if (!zipHandle)
- return NULL;
-
- // Open file
- zipHandle->zipFirst = 1;
- zipHandle->handle = unzOpen(zipFilename);
-
- if (zipHandle->handle)
- return zipHandle;
-
- free(zipHandle);
-#endif
- return NULL;
-}
-
-
-
-DFextZipHandleP DFextZipCreate(const char *zipFilename) {
- DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
-
-#if 0
- // no more memory
- if (!zipHandle)
- return NULL;
-
- // Open file
- zipHandle->zipFirst = 1;
- zipHandle->handle = zipOpen(zipFilename, APPEND_STATUS_CREATE);
-
- if (zipHandle->handle)
- return zipHandle;
-
- free(zipHandle);
-#endif
- return NULL;
-}
-
-
-int DFextZipClose(DFextZipHandleP zipHandle)
-{
- int rc = 0;
-
-#if 0
- if (zipHandle->handle) {
- if (zipHandle->zipFlag)
- rc = (unzClose(zipHandle->handle) == UNZ_OK);
- else
- rc = (zipClose(zipHandle->handle, NULL) == ZIP_OK);
- zipHandle->handle = NULL;
- }
-
- free(zipHandle);
-#endif
- return rc ? 1 : -1;
-}
-
-
-
-int DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName, const int maxName)
-{
-#if 0
- int rc;
-
- if (zipHandle->zipFlag) {
- unz_file_info info;
-
- // handling of first file and all others are different
- if (zipHandle->zipFirst) {
- rc = unzGoToFirstFile(zipHandle->handle);
- zipHandle->zipFirst = 0;
- }
- else
- rc = unzGoToNextFile(zipHandle->handle);
-
- // Error or past last file
- if (rc != UNZ_OK)
- return (rc == UNZ_END_OF_LIST_OF_FILE) ? 0 : -1;
-
- // get file name
- if (unzGetCurrentFileInfo(zipHandle->handle, &info, entryName, maxName, NULL, 0, NULL, 0) != UNZ_OK)
- return -1;
-
- // check for prefix "/" and if present skip file
- if (entryName[strlen(entryName) - 1] == '/')
- return DFextZipOpenNextFile(zipHandle, entryName, maxName);
-
- // open Regular file
- if (unzOpenCurrentFile(zipHandle->handle) != UNZ_OK)
- return -1;
- }
- else {
- return -1; // Zip file is open in write-only mode
- }
-
- // ready to read
-#endif
- return 1;
-}
-
-int DFextZipAppendNewFile(DFextZipHandleP zipHandle, const char *entryName)
-{
-#if 0
- zip_fileinfo fileinfo;
- memset(&fileinfo, 0, sizeof(fileinfo));
-
- if (zipHandle->zipFlag)
- return -1; // Zip file is open in read-only mode
-
- if (zipOpenNewFileInZip(zipHandle->handle,
- entryName,
- &fileinfo,
- NULL, 0,
- NULL, 0,
- NULL,
- Z_DEFLATED,
- Z_DEFAULT_COMPRESSION) != ZIP_OK) {
- return -1;
- }
-#endif
- return 1;
-}
-
-int DFextZipCloseFile(DFextZipHandleP zipHandle)
-{
-#if 0
- if (zipHandle->zipFlag)
- return (unzCloseCurrentFile(zipHandle->handle) != UNZ_OK) ? -1 : 1;
- else
- return (zipCloseFileInZip(zipHandle->handle) != UNZ_OK) ? -1 : 1;
-#endif
- return 0;
-}
-
-
-
-
-int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, void *buf, const int maxLen)
-{
-#if 0
- return unzReadCurrentFile(zipHandle->handle, buf, maxLen);
-#endif
- return 0;
-}
-
-
-
-int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, const void *buf, const int len)
-{
-#if 0
- return (zipWriteInFileInZip(zipHandle->handle, buf, len) == ZIP_OK) ? 1 : -1;
-#endif
- return 0;
-}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/1257d3f9/DocFormats/platform/src/Wrapper_zip.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper_zip.c b/DocFormats/platform/src/Wrapper_zip.c
new file mode 100644
index 0000000..e73234c
--- /dev/null
+++ b/DocFormats/platform/src/Wrapper_zip.c
@@ -0,0 +1,250 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "DFPlatform.h"
+#include "zlib.h"
+
+
+
+DFextZipHandleP DFextZipOpen(const char *zipFilename) {
+ DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
+
+ // open zip file for reading
+ zipHandle->zip = fopen(zipFilename, "rb");
+ if (!zipHandle->zip) {
+ free(zipHandle);
+ return NULL;
+ }
+
+
+ int jzReadEndRecord(FILE *zip, JZEndRecord *endRecord) {
+ long fileSize, readBytes, i;
+ JZEndRecord *er;
+
+ if (fseek(zip, 0, SEEK_END)) {
+ fprintf(stderr, "Couldn't go to end of zip file!");
+ return Z_ERRNO;
+ }
+
+ if ((fileSize = ftell(zip)) <= sizeof(JZEndRecord)) {
+ fprintf(stderr, "Too small file to be a zip!");
+ return Z_ERRNO;
+ }
+
+ readBytes = (fileSize < sizeof(jzBuffer)) ? fileSize : sizeof(jzBuffer);
+
+ if (fseek(zip, fileSize - readBytes, SEEK_SET)) {
+ fprintf(stderr, "Cannot seek in zip file!");
+ return Z_ERRNO;
+ }
+
+ if (fread(jzBuffer, 1, readBytes, zip) < readBytes) {
+ fprintf(stderr, "Couldn't read end of zip file!");
+ return Z_ERRNO;
+ }
+
+ // Naively assume signature can only be found in one place...
+ for (i = readBytes - sizeof(JZEndRecord); i >= 0; i--) {
+ er = (JZEndRecord *)(jzBuffer + i);
+ if (er->signature == 0x06054B50)
+ break;
+ }
+
+ if (i < 0) {
+ fprintf(stderr, "End record signature not found in zip!");
+ return Z_ERRNO;
+ }
+
+ memcpy(endRecord, er, sizeof(JZEndRecord));
+
+ if (endRecord->diskNumber || endRecord->centralDirectoryDiskNumber ||
+ endRecord->numEntries != endRecord->numEntriesThisDisk) {
+ fprintf(stderr, "Multifile zips not supported!");
+ return Z_ERRNO;
+ }
+
+ return Z_OK;
+
+
+
+ // release memory
+ free(zipHandle);
+ return NULL;
+}
+
+
+
+DFextZipHandleP OLD_DFextZipOpen(const char *zipFilename) {
+ DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
+
+#if 0
+ // no more memory
+ if (!zipHandle)
+ return NULL;
+
+ // Open file
+ zipHandle->zipFirst = 1;
+ zipHandle->handle = unzOpen(zipFilename);
+
+ if (zipHandle->handle)
+ return zipHandle;
+
+ free(zipHandle);
+#endif
+ return NULL;
+}
+
+
+
+DFextZipHandleP DFextZipCreate(const char *zipFilename) {
+ DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
+
+#if 0
+ // no more memory
+ if (!zipHandle)
+ return NULL;
+
+ // Open file
+ zipHandle->zipFirst = 1;
+ zipHandle->handle = zipOpen(zipFilename, APPEND_STATUS_CREATE);
+
+ if (zipHandle->handle)
+ return zipHandle;
+
+ free(zipHandle);
+#endif
+ return NULL;
+}
+
+
+int DFextZipClose(DFextZipHandleP zipHandle)
+{
+ int rc = 0;
+
+#if 0
+ if (zipHandle->handle) {
+ if (zipHandle->zipFlag)
+ rc = (unzClose(zipHandle->handle) == UNZ_OK);
+ else
+ rc = (zipClose(zipHandle->handle, NULL) == ZIP_OK);
+ zipHandle->handle = NULL;
+ }
+
+ free(zipHandle);
+#endif
+ return rc ? 1 : -1;
+}
+
+
+
+int DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName, const int maxName)
+{
+#if 0
+ int rc;
+
+ if (zipHandle->zipFlag) {
+ unz_file_info info;
+
+ // handling of first file and all others are different
+ if (zipHandle->zipFirst) {
+ rc = unzGoToFirstFile(zipHandle->handle);
+ zipHandle->zipFirst = 0;
+ }
+ else
+ rc = unzGoToNextFile(zipHandle->handle);
+
+ // Error or past last file
+ if (rc != UNZ_OK)
+ return (rc == UNZ_END_OF_LIST_OF_FILE) ? 0 : -1;
+
+ // get file name
+ if (unzGetCurrentFileInfo(zipHandle->handle, &info, entryName, maxName, NULL, 0, NULL, 0) != UNZ_OK)
+ return -1;
+
+ // check for prefix "/" and if present skip file
+ if (entryName[strlen(entryName) - 1] == '/')
+ return DFextZipOpenNextFile(zipHandle, entryName, maxName);
+
+ // open Regular file
+ if (unzOpenCurrentFile(zipHandle->handle) != UNZ_OK)
+ return -1;
+ }
+ else {
+ return -1; // Zip file is open in write-only mode
+ }
+
+ // ready to read
+#endif
+ return 1;
+}
+
+int DFextZipAppendNewFile(DFextZipHandleP zipHandle, const char *entryName)
+{
+#if 0
+ zip_fileinfo fileinfo;
+ memset(&fileinfo, 0, sizeof(fileinfo));
+
+ if (zipHandle->zipFlag)
+ return -1; // Zip file is open in read-only mode
+
+ if (zipOpenNewFileInZip(zipHandle->handle,
+ entryName,
+ &fileinfo,
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ Z_DEFLATED,
+ Z_DEFAULT_COMPRESSION) != ZIP_OK) {
+ return -1;
+ }
+#endif
+ return 1;
+}
+
+int DFextZipCloseFile(DFextZipHandleP zipHandle)
+{
+#if 0
+ if (zipHandle->zipFlag)
+ return (unzCloseCurrentFile(zipHandle->handle) != UNZ_OK) ? -1 : 1;
+ else
+ return (zipCloseFileInZip(zipHandle->handle) != UNZ_OK) ? -1 : 1;
+#endif
+ return 0;
+}
+
+
+
+
+int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, void *buf, const int maxLen)
+{
+#if 0
+ return unzReadCurrentFile(zipHandle->handle, buf, maxLen);
+#endif
+ return 0;
+}
+
+
+
+int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, const void *buf, const int len)
+{
+#if 0
+ return (zipWriteInFileInZip(zipHandle->handle, buf, len) == ZIP_OK) ? 1 : -1;
+#endif
+ return 0;
+}
[2/3] incubator-corinthia git commit: rename testcass and prepare
Posted by ja...@apache.org.
rename testcass and prepare
prepare for new impl. of read
Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/be6c3ce9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/be6c3ce9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/be6c3ce9
Branch: refs/heads/newZipExperiment
Commit: be6c3ce947750156bc0cb18b7db561fdbd1bca69
Parents: 8462afc
Author: jani <ja...@apache.org>
Authored: Tue Jul 28 20:10:54 2015 +0200
Committer: jani <ja...@apache.org>
Committed: Tue Jul 28 20:10:54 2015 +0200
----------------------------------------------------------------------
DocFormats/headers/DFPlatform.h | 4 +--
DocFormats/platform/src/Wrapper.c | 52 ++++++++++++++++++++++-----
DocFormats/platform/tests/WrapperTests.c | 22 ++++++++----
3 files changed, 61 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/be6c3ce9/DocFormats/headers/DFPlatform.h
----------------------------------------------------------------------
diff --git a/DocFormats/headers/DFPlatform.h b/DocFormats/headers/DFPlatform.h
index 8e10fdb..d594779 100644
--- a/DocFormats/headers/DFPlatform.h
+++ b/DocFormats/headers/DFPlatform.h
@@ -70,9 +70,7 @@ void DFInitOnce(DFOnce *once, DFOnceFunction fun);
// Zip functions
typedef struct {
- void *handle;
- int zipFlag;
- int zipFirst;
+ int x;
} DFextZipHandle;
typedef DFextZipHandle * DFextZipHandleP;
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/be6c3ce9/DocFormats/platform/src/Wrapper.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper.c b/DocFormats/platform/src/Wrapper.c
index b9f37fe..1ca4ef2 100644
--- a/DocFormats/platform/src/Wrapper.c
+++ b/DocFormats/platform/src/Wrapper.c
@@ -25,41 +25,64 @@
DFextZipHandleP DFextZipOpen(const char *zipFilename) {
DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
-
+#if 0
// no more memory
if (!zipHandle)
return NULL;
// Open file
zipHandle->zipFirst = 1;
- zipHandle->zipFlag = 1;
zipHandle->handle = unzOpen(zipFilename);
if (zipHandle->handle)
return zipHandle;
free(zipHandle);
+#endif
return NULL;
}
+DFextZipHandleP OLD_DFextZipOpen(const char *zipFilename) {
+ DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
+
+#if 0
+ // no more memory
+ if (!zipHandle)
+ return NULL;
+
+ // Open file
+ zipHandle->zipFirst = 1;
+ zipHandle->handle = unzOpen(zipFilename);
+
+ if (zipHandle->handle)
+ return zipHandle;
+
+ free(zipHandle);
+#endif
+ return NULL;
+}
+
+
+
DFextZipHandleP DFextZipCreate(const char *zipFilename) {
DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
+#if 0
// no more memory
if (!zipHandle)
return NULL;
// Open file
zipHandle->zipFirst = 1;
- zipHandle->zipFlag = 0;
zipHandle->handle = zipOpen(zipFilename, APPEND_STATUS_CREATE);
if (zipHandle->handle)
return zipHandle;
free(zipHandle);
+#endif
return NULL;
}
@@ -68,6 +91,7 @@ int DFextZipClose(DFextZipHandleP zipHandle)
{
int rc = 0;
+#if 0
if (zipHandle->handle) {
if (zipHandle->zipFlag)
rc = (unzClose(zipHandle->handle) == UNZ_OK);
@@ -77,6 +101,7 @@ int DFextZipClose(DFextZipHandleP zipHandle)
}
free(zipHandle);
+#endif
return rc ? 1 : -1;
}
@@ -84,8 +109,8 @@ int DFextZipClose(DFextZipHandleP zipHandle)
int DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName, const int maxName)
{
- int rc;
-
+#if 0
+ int rc;
if (zipHandle->zipFlag) {
unz_file_info info;
@@ -119,16 +144,18 @@ int DFextZipOpenNextFile(DFextZipHandleP zipHandle, char *entryName, const int m
}
// ready to read
+#endif
return 1;
}
int DFextZipAppendNewFile(DFextZipHandleP zipHandle, const char *entryName)
{
+#if 0
zip_fileinfo fileinfo;
memset(&fileinfo, 0, sizeof(fileinfo));
- if (zipHandle->zipFlag)
- return -1; // Zip file is open in read-only mode
+ if (zipHandle->zipFlag)
+ return -1; // Zip file is open in read-only mode
if (zipOpenNewFileInZip(zipHandle->handle,
entryName,
@@ -140,16 +167,19 @@ int DFextZipAppendNewFile(DFextZipHandleP zipHandle, const char *entryName)
Z_DEFAULT_COMPRESSION) != ZIP_OK) {
return -1;
}
-
+#endif
return 1;
}
int DFextZipCloseFile(DFextZipHandleP zipHandle)
{
+#if 0
if (zipHandle->zipFlag)
return (unzCloseCurrentFile(zipHandle->handle) != UNZ_OK) ? -1 : 1;
else
return (zipCloseFileInZip(zipHandle->handle) != UNZ_OK) ? -1 : 1;
+#endif
+ return 0;
}
@@ -157,14 +187,20 @@ int DFextZipCloseFile(DFextZipHandleP zipHandle)
int DFextZipReadCurrentFile(DFextZipHandleP zipHandle, void *buf, const int maxLen)
{
+#if 0
return unzReadCurrentFile(zipHandle->handle, buf, maxLen);
+#endif
+ return 0;
}
int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, const void *buf, const int len)
{
+#if 0
return (zipWriteInFileInZip(zipHandle->handle, buf, len) == ZIP_OK) ? 1 : -1;
+#endif
+ return 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/be6c3ce9/DocFormats/platform/tests/WrapperTests.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/tests/WrapperTests.c b/DocFormats/platform/tests/WrapperTests.c
index 5f5d74b..19ed4ae 100644
--- a/DocFormats/platform/tests/WrapperTests.c
+++ b/DocFormats/platform/tests/WrapperTests.c
@@ -29,6 +29,15 @@ static void test_DFextZipOpen(void)
+static void test_DFextZipCreate(void)
+{
+#if 0
+ int DFextZipOpen(const char *zipFilename, int doUnzip) {
+#endif
+}
+
+
+
static void test_DFextZipClose(void)
{
#if 0
@@ -76,12 +85,13 @@ static void test_DFextZipWriteCurrentFile(void)
TestGroup PlatformWrapperTests = {
"platform.wrapper", {
- { "DFextZipOpen", PlainTest, test_DFextZipOpen },
- { "DFextZipClose", PlainTest, test_DFextZipClose },
- { "DFextZipOpenNextFile", PlainTest, test_DFextZipOpenNextFile },
- { "DFextZipCloseFile", PlainTest, test_DFextZipCloseFile },
- { "DFextZipReadCurrentFile", PlainTest, test_DFextZipReadCurrentFile },
+ { "DFextZipOpen", PlainTest, test_DFextZipCreate },
+ { "DFextZipOpen", PlainTest, test_DFextZipOpen },
+ { "DFextZipClose", PlainTest, test_DFextZipClose },
+ { "DFextZipOpenNextFile", PlainTest, test_DFextZipOpenNextFile },
+ { "DFextZipCloseFile", PlainTest, test_DFextZipCloseFile },
+ { "DFextZipReadCurrentFile", PlainTest, test_DFextZipReadCurrentFile },
{ "DFextZipWriteCurrentFile", PlainTest, test_DFextZipWriteCurrentFile },
- { NULL, PlainTest, NULL }
+ { NULL, PlainTest, NULL }
}
};