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/01 21:52:54 UTC

[1/2] incubator-corinthia git commit: work

Repository: incubator-corinthia
Updated Branches:
  refs/heads/newZipExperiment2 b53aa9e01 -> 71296b80d


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/3af27c1a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/3af27c1a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/3af27c1a

Branch: refs/heads/newZipExperiment2
Commit: 3af27c1ab265db5301b670d828328b102079054f
Parents: b53aa9e
Author: jani <ja...@apache.org>
Authored: Sat Aug 1 21:43:56 2015 +0200
Committer: jani <ja...@apache.org>
Committed: Sat Aug 1 21:43:56 2015 +0200

----------------------------------------------------------------------
 DocFormats/platform/src/Wrapper_zip.c    | 22 ++++++++++++++--------
 DocFormats/platform/tests/WrapperTests.c |  5 +++++
 2 files changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/3af27c1a/DocFormats/platform/src/Wrapper_zip.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper_zip.c b/DocFormats/platform/src/Wrapper_zip.c
index dac3523..ab6f8ee 100644
--- a/DocFormats/platform/src/Wrapper_zip.c
+++ b/DocFormats/platform/src/Wrapper_zip.c
@@ -206,17 +206,24 @@ DFextZipHandleP DFextZipOpen(const char *zipFilename) {
 }
 
 
-
 unsigned char *DFextZipReadFile(DFextZipHandleP zipHandle, DFextZipDirEntryP zipEntry) {
 	unsigned char *fileBuf = xmalloc(zipEntry->uncompressedSize);
 
-#if 0
-	// Some files are uncompressed
-	if (zipFile->compressionMethod == 0) {
-		if (fread(buffer, 1, header->uncompressedSize, zip) <
-			header->uncompressedSize || ferror(zip))
-			return Z_ERRNO;
+	// Position in front of file
+	if (fseek(zipHandle->zipFile, zipEntry->offset, SEEK_SET)) {
+		free(fileBuf);
+		return NULL;
+	}
+
+	// interesting a zip file that is uncompressed, have to handle that
+	if (zipEntry->compressionMethod == 0
+		&& (fread(fileBuf, 1, zipEntry->uncompressedSize, zipHandle->zipFile) < zipEntry->uncompressedSize
+			|| ferror(zipHandle->zipFile))) {
+		free(fileBuf);
+		return NULL;
 	}
+
+#if 0
 	unsigned char *bytes = (unsigned char *)buffer; // cast
 	long compressedLeft, uncompressedLeft;
 	z_stream strm;
@@ -277,7 +284,6 @@ unsigned char *DFextZipReadFile(DFextZipHandleP zipHandle, DFextZipDirEntryP zip
 		return Z_ERRNO;
 	}
 #endif
-	return Z_OK;
 	return NULL;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/3af27c1a/DocFormats/platform/tests/WrapperTests.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/tests/WrapperTests.c b/DocFormats/platform/tests/WrapperTests.c
index efe2f66..fcf5979 100644
--- a/DocFormats/platform/tests/WrapperTests.c
+++ b/DocFormats/platform/tests/WrapperTests.c
@@ -25,8 +25,13 @@
 static void test_DFextZipOpen(void)
 {
 	DFextZipHandleP zip;
+	int             i;
+	unsigned char  *fileBuf;
 
 	zip = DFextZipOpen("test.docx");
+	for (i = 0; i < zip->zipFileCount; i++) {
+		fileBuf = DFextZipReadFile(zip, &zip->zipFileEntries[i]);
+	}
 	zip = DFextZipOpen("test.odt");
 }
 


[2/2] 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/71296b80
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/71296b80
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/71296b80

Branch: refs/heads/newZipExperiment2
Commit: 71296b80d248cf46e9e5610deb37dcbf39ee492a
Parents: 3af27c1
Author: jani <ja...@apache.org>
Authored: Sat Aug 1 21:52:34 2015 +0200
Committer: jani <ja...@apache.org>
Committed: Sat Aug 1 21:52:34 2015 +0200

----------------------------------------------------------------------
 DocFormats/platform/src/Wrapper_zip.c    |  2 +-
 DocFormats/platform/tests/WrapperTests.c | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/71296b80/DocFormats/platform/src/Wrapper_zip.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper_zip.c b/DocFormats/platform/src/Wrapper_zip.c
index ab6f8ee..cccc75f 100644
--- a/DocFormats/platform/src/Wrapper_zip.c
+++ b/DocFormats/platform/src/Wrapper_zip.c
@@ -217,7 +217,7 @@ unsigned char *DFextZipReadFile(DFextZipHandleP zipHandle, DFextZipDirEntryP zip
 
 	// interesting a zip file that is uncompressed, have to handle that
 	if (zipEntry->compressionMethod == 0
-		&& (fread(fileBuf, 1, zipEntry->uncompressedSize, zipHandle->zipFile) < zipEntry->uncompressedSize
+		&& (fread(fileBuf, 1, zipEntry->uncompressedSize, zipHandle->zipFile) < (unsigned long)zipEntry->uncompressedSize
 			|| ferror(zipHandle->zipFile))) {
 		free(fileBuf);
 		return NULL;

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/71296b80/DocFormats/platform/tests/WrapperTests.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/tests/WrapperTests.c b/DocFormats/platform/tests/WrapperTests.c
index fcf5979..81dab7a 100644
--- a/DocFormats/platform/tests/WrapperTests.c
+++ b/DocFormats/platform/tests/WrapperTests.c
@@ -27,12 +27,31 @@ static void test_DFextZipOpen(void)
 	DFextZipHandleP zip;
 	int             i;
 	unsigned char  *fileBuf;
+	char            tmpName[20];
+	FILE           *log, *dmp;
 
 	zip = DFextZipOpen("test.docx");
+	log = fopen("docx_log.txt", "w");
 	for (i = 0; i < zip->zipFileCount; i++) {
 		fileBuf = DFextZipReadFile(zip, &zip->zipFileEntries[i]);
+		fprintf(log, "id(%d) name(%s)\n", i, zip->zipFileEntries[i].fileName);
+		sprintf(tmpName, "docx_%d.xxx", i);
+		dmp = fopen(tmpName, "wb");
+		fwrite(fileBuf, 1, zip->zipFileEntries[i].uncompressedSize, dmp);
+		fclose(dmp);
 	}
+	fclose(log);
 	zip = DFextZipOpen("test.odt");
+	log = fopen("odt_log.txt", "w");
+	for (i = 0; i < zip->zipFileCount; i++) {
+		fileBuf = DFextZipReadFile(zip, &zip->zipFileEntries[i]);
+		fprintf(log, "id(%d) name(%s)\n", i, zip->zipFileEntries[i].fileName);
+		sprintf(tmpName, "odt_%d.xxx", i);
+		dmp = fopen(tmpName, "wb");
+		fwrite(fileBuf, 1, zip->zipFileEntries[i].uncompressedSize, dmp);
+		fclose(dmp);
+	}
+	fclose(log);
 }