zipCreate main finished
Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/00878c33
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/00878c33
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/00878c33
Branch: refs/heads/newZipExperiment2
Commit: 00878c339edb8d22fa9b3e46a7b38ba1dc2705e7
Parents: 7f0e44f
Author: jani <jani@apache.org>
Authored: Mon Aug 3 19:25:05 2015 +0200
Committer: jani <jani@apache.org>
Committed: Mon Aug 3 19:25:05 2015 +0200
----------------------------------------------------------------------
DocFormats/headers/DFPlatform.h | 1 +
DocFormats/platform/src/Wrapper_zip.c | 12 ++++++++----
2 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/00878c33/DocFormats/headers/DFPlatform.h
----------------------------------------------------------------------
diff --git a/DocFormats/headers/DFPlatform.h b/DocFormats/headers/DFPlatform.h
index e8ed0d7..a6b4e2d 100644
--- a/DocFormats/headers/DFPlatform.h
+++ b/DocFormats/headers/DFPlatform.h
@@ -80,6 +80,7 @@ typedef DFextZipDirEntry * DFextZipDirEntryP;
typedef struct {
void *zipFile; // file handle to zip file
int zipFileCount; // number of entries in array
+ int zipCreateMode; // > 0 signals create mode, # is allocation of array
DFextZipDirEntry *zipFileEntries; // array with filenames in zip
} DFextZipHandle;
typedef DFextZipHandle * DFextZipHandleP;
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/00878c33/DocFormats/platform/src/Wrapper_zip.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper_zip.c b/DocFormats/platform/src/Wrapper_zip.c
index 2ff53fe..a653019 100644
--- a/DocFormats/platform/src/Wrapper_zip.c
+++ b/DocFormats/platform/src/Wrapper_zip.c
@@ -194,7 +194,8 @@ DFextZipHandleP DFextZipOpen(const char *zipFilename) {
DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
// open zip file for reading
- zipHandle->zipFile = fopen(zipFilename, "rb");
+ zipHandle->zipCreateMode = 0;
+ zipHandle->zipFile = fopen(zipFilename, "rb");
if (zipHandle->zipFile
&& !readDirectory(zipHandle->zipFile, zipHandle))
return zipHandle;
@@ -273,9 +274,6 @@ unsigned char *DFextZipReadFile(DFextZipHandleP zipHandle, DFextZipDirEntryP
zip
-
-
-
DFextZipHandleP DFextZipCreate(const char *zipFilename) {
DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
@@ -284,6 +282,12 @@ DFextZipHandleP DFextZipCreate(const char *zipFilename) {
free(zipHandle);
return NULL;
}
+
+ // prepare to add files
+ zipHandle->zipFileCount = 0;
+ zipHandle->zipCreateMode = 5;
+ zipHandle->zipFileEntries = xmalloc(zipHandle->zipCreateMode * sizeof(DFextZipDirEntry));
+ memset(zipHandle->zipFileEntries, 1, zipHandle->zipCreateMode * sizeof(DFextZipDirEntry));
return zipHandle;
}
|