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/08/03 21:59:39 UTC
[3/5] incubator-corinthia git commit: integrate new zipCreate in
dfzip.c
integrate new zipCreate in dfzip.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/c8c35ec4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/c8c35ec4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/c8c35ec4
Branch: refs/heads/newZipExperiment2
Commit: c8c35ec4ba88ff11f173cf2606d6342232152f8d
Parents: 00878c3
Author: jani <ja...@apache.org>
Authored: Mon Aug 3 20:03:28 2015 +0200
Committer: jani <ja...@apache.org>
Committed: Mon Aug 3 20:03:28 2015 +0200
----------------------------------------------------------------------
DocFormats/core/src/lib/DFZipFile.c | 8 +----
DocFormats/headers/DFPlatform.h | 12 ++------
DocFormats/platform/src/Wrapper_zip.c | 47 +++++-------------------------
3 files changed, 11 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/c8c35ec4/DocFormats/core/src/lib/DFZipFile.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFZipFile.c b/DocFormats/core/src/lib/DFZipFile.c
index b3dab37..61dcf1b 100644
--- a/DocFormats/core/src/lib/DFZipFile.c
+++ b/DocFormats/core/src/lib/DFZipFile.c
@@ -68,14 +68,8 @@ int DFUnzip(const char *zipFilename, DFStorage *storage, DFError **error)
static int zipAddFile(DFextZipHandleP zipHandle, const char *dest, DFBuffer *content, DFError **error)
{
- if (DFextZipAppendNewFile(zipHandle, dest) < 0)
+ if (DFextZipWriteFile(zipHandle, dest, content->data, content->len) < 0)
return zipError(error,"%s: Cannot create entry in zip file",dest);
-
- if (DFextZipWriteCurrentFile(zipHandle, content->data, (unsigned int)content->len) < 0)
- return zipError(error,"%s: Error writing to entry in zip file",dest);
-
- if (DFextZipCloseFile(zipHandle) <0)
- return zipError(error,"%s: Error closing entry in zip file",dest);
return 1;
}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/c8c35ec4/DocFormats/headers/DFPlatform.h
----------------------------------------------------------------------
diff --git a/DocFormats/headers/DFPlatform.h b/DocFormats/headers/DFPlatform.h
index a6b4e2d..fb5f55f 100644
--- a/DocFormats/headers/DFPlatform.h
+++ b/DocFormats/headers/DFPlatform.h
@@ -89,19 +89,11 @@ typedef DFextZipHandle * DFextZipHandleP;
DFextZipHandleP DFextZipOpen(const char *zipFilename);
DFextZipHandleP DFextZipCreate(const char *zipFilename);
-unsigned char *DFextZipReadFile(DFextZipHandleP zipHandle, DFextZipDirEntryP zipEntry);
-
-
-
+unsigned char *DFextZipReadFile(DFextZipHandleP zipHandle, DFextZipDirEntryP zipEntry);
+DFextZipDirEntryP DFextZipWriteFile(DFextZipHandleP zipHandle, const char *fileName, const void *buf, const int len);
int DFextZipClose(DFextZipHandleP zipHandle);
-int DFextZipAppendNewFile(DFextZipHandleP zipHandle,
- const char *entryName);
-
-int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle,
- const void *buf,
- const int len);
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/c8c35ec4/DocFormats/platform/src/Wrapper_zip.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper_zip.c b/DocFormats/platform/src/Wrapper_zip.c
index a653019..5120787 100644
--- a/DocFormats/platform/src/Wrapper_zip.c
+++ b/DocFormats/platform/src/Wrapper_zip.c
@@ -176,8 +176,9 @@ static int readDirectory(FILE *zipFile, DFextZipHandleP zipHandle)
static void releaseMemory(DFextZipHandleP zipHandle) {
if (zipHandle) {
- if (zipHandle->zipFileEntries) {
- for (int i = 0; i < zipHandle->zipFileCount; i++) {
+ int count = zipHandle->zipCreateMode ? zipHandle->zipCreateMode : zipHandle->zipFileEntries;
+ if (count) {
+ for (int i = 0; i < count; i++) {
DFextZipDirEntry *zipDirEntry = zipHandle->zipFileEntries + (i * sizeof(zipDirEntry));
if (zipDirEntry->fileName)
free(zipDirEntry->fileName);
@@ -292,48 +293,16 @@ DFextZipHandleP DFextZipCreate(const char *zipFilename) {
}
-int DFextZipClose(DFextZipHandleP zipHandle)
-{
- fclose(zipHandle->zipFile);
- releaseMemory(zipHandle);
- return 0;
-}
-
-
-int DFextZipCloseFile(DFextZipHandleP zipHandle) {
- return 0;
-}
-
-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;
+DFextZipDirEntryP DFextZipWriteFile(DFextZipHandleP zipHandle, const char *fileName, const void *buf, const int len) {
+ return NULL;
}
-int DFextZipWriteCurrentFile(DFextZipHandleP zipHandle, const void *buf, const int len)
+int DFextZipClose(DFextZipHandleP zipHandle)
{
-#if 0
- return (zipWriteInFileInZip(zipHandle->handle, buf, len) == ZIP_OK) ? 1 : -1;
-#endif
+ fclose(zipHandle->zipFile);
+ releaseMemory(zipHandle);
return 0;
}