corinthia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmke...@apache.org
Subject [80/92] [abbrv] incubator-corinthia git commit: Rename DFPackage to DFStorage
Date Wed, 17 Dec 2014 13:29:30 GMT
Rename DFPackage to DFStorage

The term 'storage' more appropriately describes the role of this class -
that is, an abstraction layer over different physical storage mechanisms
(filesystem, zip file, memory). Using this term also avoids confusion
with the higher-level 'package' classes used for OOXML and ODF.


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

Branch: refs/heads/stable
Commit: 8337d187718bbc131cf572a7a49b03f9966d7f14
Parents: 9126682
Author: Peter Kelly <peter@uxproductivity.com>
Authored: Mon Dec 8 14:27:38 2014 +0700
Committer: Peter Kelly <peter@uxproductivity.com>
Committed: Mon Dec 8 14:27:38 2014 +0700

----------------------------------------------------------------------
 DocFormats.xcodeproj/project.pbxproj            |  24 +-
 DocFormats/CMakeLists.txt                       |   4 +-
 DocFormats/api/headers/DocFormats/Operations.h  |   6 +-
 DocFormats/api/src/Operations.c                 |  70 +--
 DocFormats/core/src/lib/DFBuffer.c              |   8 +-
 DocFormats/core/src/lib/DFBuffer.h              |   6 +-
 DocFormats/core/src/lib/DFPackage.c             | 440 ------------------
 DocFormats/core/src/lib/DFPackage.h             |  39 --
 DocFormats/core/src/lib/DFStorage.c             | 441 +++++++++++++++++++
 DocFormats/core/src/lib/DFStorage.h             |  39 ++
 DocFormats/core/src/lib/DFZipFile.c             |  10 +-
 DocFormats/core/src/lib/DFZipFile.h             |   6 +-
 DocFormats/core/src/xml/DFXML.c                 |  10 +-
 DocFormats/core/src/xml/DFXML.h                 |  10 +-
 DocFormats/filters/ooxml/src/common/OPC.c       |  48 +-
 DocFormats/filters/ooxml/src/common/OPC.h       |   8 +-
 DocFormats/filters/ooxml/src/word/Word.c        |  26 +-
 DocFormats/filters/ooxml/src/word/Word.h        |  12 +-
 .../filters/ooxml/src/word/WordConverter.c      |   8 +-
 .../filters/ooxml/src/word/WordConverter.h      |   6 +-
 DocFormats/filters/ooxml/src/word/WordGC.c      |   2 +-
 DocFormats/filters/ooxml/src/word/WordPackage.c |  24 +-
 DocFormats/filters/ooxml/src/word/WordPackage.h |  10 +-
 .../filters/ooxml/src/word/lenses/WordDrawing.c |  28 +-
 consumers/dfutil/src/Commands.c                 |  20 +-
 consumers/dfutil/src/Plain.c                    | 102 ++---
 consumers/dfutil/src/Plain.h                    |  10 +-
 consumers/dfutil/src/TestCase.c                 |   6 +-
 consumers/dfutil/src/TestCase.h                 |   6 +-
 consumers/dfutil/src/TestFunctions.c            |  88 ++--
 consumers/dfutil/src/main.c                     |  12 +-
 31 files changed, 765 insertions(+), 764 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/DocFormats.xcodeproj/project.pbxproj b/DocFormats.xcodeproj/project.pbxproj
index 3cd558a..2b7ee55 100644
--- a/DocFormats.xcodeproj/project.pbxproj
+++ b/DocFormats.xcodeproj/project.pbxproj
@@ -177,6 +177,10 @@
 		D04459461A20636F00A2E37E /* ODFSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = D04459361A20635B00A2E37E /* ODFSheet.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		D074ED581A2B04BC000C3704 /* DocFormats.h in Headers */ = {isa = PBXBuildFile; fileRef = D074ED561A2B04BC000C3704 /* DocFormats.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		D074ED591A2B04BC000C3704 /* Operations.h in Headers */ = {isa = PBXBuildFile; fileRef = D074ED571A2B04BC000C3704 /* Operations.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		D078117A1A35801200768ACF /* DFStorage.c in Sources */ = {isa = PBXBuildFile; fileRef = D07811781A35801200768ACF /* DFStorage.c */; };
+		D078117B1A35801200768ACF /* DFStorage.c in Sources */ = {isa = PBXBuildFile; fileRef = D07811781A35801200768ACF /* DFStorage.c */; };
+		D078117C1A35801200768ACF /* DFStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = D07811791A35801200768ACF /* DFStorage.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		D078117D1A35801200768ACF /* DFStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = D07811791A35801200768ACF /* DFStorage.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		D0A1283317EF7E9D005FE158 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0A1283217EF7E9D005FE158 /* Cocoa.framework */; };
 		D0A1283D17EF7E9D005FE158 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = D0A1283B17EF7E9D005FE158 /* InfoPlist.strings */; };
 		D0A1286317EF7ED5005FE158 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0A1286217EF7ED5005FE158 /* Foundation.framework */; };
@@ -443,10 +447,6 @@
 		D0BC4165198413F500882CD1 /* DFTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = D0BC4163198413B900882CD1 /* DFTypes.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		D0FA2D821A2B05B400B44D96 /* DocFormats.h in Headers */ = {isa = PBXBuildFile; fileRef = D074ED561A2B04BC000C3704 /* DocFormats.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		D0FA2D831A2B05B400B44D96 /* Operations.h in Headers */ = {isa = PBXBuildFile; fileRef = D074ED571A2B04BC000C3704 /* Operations.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		D0FBA10A1A2B16F700B066C1 /* DFPackage.c in Sources */ = {isa = PBXBuildFile; fileRef = D0FBA1081A2B16F700B066C1 /* DFPackage.c */; };
-		D0FBA10B1A2B16F700B066C1 /* DFPackage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FBA1091A2B16F700B066C1 /* DFPackage.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		D0FBA10C1A2B173000B066C1 /* DFPackage.c in Sources */ = {isa = PBXBuildFile; fileRef = D0FBA1081A2B16F700B066C1 /* DFPackage.c */; };
-		D0FBA10D1A2B173000B066C1 /* DFPackage.h in Headers */ = {isa = PBXBuildFile; fileRef = D0FBA1091A2B16F700B066C1 /* DFPackage.h */; settings = {ATTRIBUTES = (Public, ); }; };
 /* End PBXBuildFile section */
 
 /* Begin PBXCopyFilesBuildPhase section */
@@ -548,6 +548,8 @@
 		D04459361A20635B00A2E37E /* ODFSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ODFSheet.h; sourceTree = "<group>"; };
 		D074ED561A2B04BC000C3704 /* DocFormats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DocFormats.h; path = api/headers/DocFormats/DocFormats.h; sourceTree = "<group>"; };
 		D074ED571A2B04BC000C3704 /* Operations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Operations.h; path = api/headers/DocFormats/Operations.h; sourceTree = "<group>"; };
+		D07811781A35801200768ACF /* DFStorage.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DFStorage.c; sourceTree = "<group>"; };
+		D07811791A35801200768ACF /* DFStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFStorage.h; sourceTree = "<group>"; };
 		D0A1282F17EF7E9D005FE158 /* DocFormats.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DocFormats.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		D0A1283217EF7E9D005FE158 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
 		D0A1283517EF7E9D005FE158 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -697,8 +699,6 @@
 		D0B5E8C417F086ED00FBD99F /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/libiconv.dylib; sourceTree = DEVELOPER_DIR; };
 		D0BC41601984101D00882CD1 /* DFCommon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DFCommon.h; sourceTree = "<group>"; };
 		D0BC4163198413B900882CD1 /* DFTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DFTypes.h; sourceTree = "<group>"; };
-		D0FBA1081A2B16F700B066C1 /* DFPackage.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DFPackage.c; sourceTree = "<group>"; };
-		D0FBA1091A2B16F700B066C1 /* DFPackage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFPackage.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -841,8 +841,8 @@
 				D01E24451A205A1500F4C04D /* DFFilesystem.h */,
 				D01E24461A205A1500F4C04D /* DFHashTable.c */,
 				D01E24471A205A1500F4C04D /* DFHashTable.h */,
-				D0FBA1081A2B16F700B066C1 /* DFPackage.c */,
-				D0FBA1091A2B16F700B066C1 /* DFPackage.h */,
+				D07811781A35801200768ACF /* DFStorage.c */,
+				D07811791A35801200768ACF /* DFStorage.h */,
 				D01E244A1A205A1500F4C04D /* DFString.c */,
 				D01E244B1A205A1500F4C04D /* DFString.h */,
 				D01E244C1A205A1500F4C04D /* DFZipFile.c */,
@@ -1227,7 +1227,6 @@
 				D0A787901A210EA900723FE8 /* version.h in Headers */,
 				D01E24E71A205A1500F4C04D /* DFXMLForward.h in Headers */,
 				D0ADB38C1A2054C6003D645D /* WordNumbering.h in Headers */,
-				D0FBA10B1A2B16F700B066C1 /* DFPackage.h in Headers */,
 				D01E24891A205A1500F4C04D /* CSSSyntax.h in Headers */,
 				D01E24E11A205A1500F4C04D /* DFNameMap.h in Headers */,
 				D01E245F1A205A1500F4C04D /* DFBDT.h in Headers */,
@@ -1251,6 +1250,7 @@
 				D01E24791A205A1500F4C04D /* CSSProperties.h in Headers */,
 				D01E24751A205A1500F4C04D /* CSSParser.h in Headers */,
 				D0165ADE1A206A4D000F1267 /* DFPlatform.h in Headers */,
+				D078117C1A35801200768ACF /* DFStorage.h in Headers */,
 				D01E24D91A205A1500F4C04D /* DFDOM.h in Headers */,
 				D0ADB3641A2054C6003D645D /* WordLenses.h in Headers */,
 				D0A786941A210EA900723FE8 /* zip.h in Headers */,
@@ -1338,7 +1338,6 @@
 				D0A787911A210EA900723FE8 /* version.h in Headers */,
 				D01E24CA1A205A1500F4C04D /* DFString.h in Headers */,
 				D01E24E81A205A1500F4C04D /* DFXMLForward.h in Headers */,
-				D0FBA10D1A2B173000B066C1 /* DFPackage.h in Headers */,
 				D0ADB3391A2054C6003D645D /* WordCommonPr.h in Headers */,
 				D01E248A1A205A1500F4C04D /* CSSSyntax.h in Headers */,
 				D01E24E21A205A1500F4C04D /* DFNameMap.h in Headers */,
@@ -1362,6 +1361,7 @@
 				D01E247A1A205A1500F4C04D /* CSSProperties.h in Headers */,
 				D0165AE71A206A7A000F1267 /* DFPlatform.h in Headers */,
 				D01E24761A205A1500F4C04D /* CSSParser.h in Headers */,
+				D078117D1A35801200768ACF /* DFStorage.h in Headers */,
 				D01E24DA1A205A1500F4C04D /* DFDOM.h in Headers */,
 				D0A786951A210EA900723FE8 /* zip.h in Headers */,
 				D04459421A20636F00A2E37E /* ODFManifest.h in Headers */,
@@ -1585,6 +1585,7 @@
 				D0A7875C1A210EA900723FE8 /* gdoc.c in Sources */,
 				D01E24971A205A1500F4C04D /* DFHTMLTables.c in Sources */,
 				D0ADB3A21A2054C6003D645D /* WordStyles.c in Sources */,
+				D078117A1A35801200768ACF /* DFStorage.c in Sources */,
 				D0ADB37E1A2054C6003D645D /* WordGC.c in Sources */,
 				D0ADB3421A2054C6003D645D /* WordRPr.c in Sources */,
 				D0ADB3821A2054C6003D645D /* WordLists.c in Sources */,
@@ -1619,7 +1620,6 @@
 				D0ADB3921A2054C6003D645D /* WordPackage.c in Sources */,
 				D01E24DB1A205A1500F4C04D /* DFMarkupCompatibility.c in Sources */,
 				D0A7873E1A210EA900723FE8 /* attrget.c in Sources */,
-				D0FBA10A1A2B16F700B066C1 /* DFPackage.c in Sources */,
 				D01E24D31A205A1500F4C04D /* DFXMLNamespaces.c in Sources */,
 				D01E24AB1A205A1500F4C04D /* DFBuffer.c in Sources */,
 			);
@@ -1704,6 +1704,7 @@
 				D0A7875D1A210EA900723FE8 /* gdoc.c in Sources */,
 				D01E24981A205A1500F4C04D /* DFHTMLTables.c in Sources */,
 				D0ADB3A31A2054C6003D645D /* WordStyles.c in Sources */,
+				D078117B1A35801200768ACF /* DFStorage.c in Sources */,
 				D0ADB37F1A2054C6003D645D /* WordGC.c in Sources */,
 				D0ADB3431A2054C6003D645D /* WordRPr.c in Sources */,
 				D0ADB3831A2054C6003D645D /* WordLists.c in Sources */,
@@ -1738,7 +1739,6 @@
 				D01E24DC1A205A1500F4C04D /* DFMarkupCompatibility.c in Sources */,
 				D01E24D41A205A1500F4C04D /* DFXMLNamespaces.c in Sources */,
 				D0A7873F1A210EA900723FE8 /* attrget.c in Sources */,
-				D0FBA10C1A2B173000B066C1 /* DFPackage.c in Sources */,
 				D0ADB3931A2054C6003D645D /* WordPackage.c in Sources */,
 				D01E24AC1A205A1500F4C04D /* DFBuffer.c in Sources */,
 			);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/DocFormats/CMakeLists.txt b/DocFormats/CMakeLists.txt
index 06e924f..d78acc9 100644
--- a/DocFormats/CMakeLists.txt
+++ b/DocFormats/CMakeLists.txt
@@ -115,10 +115,10 @@ set(GroupCoreLib
     core/src/lib/DFFilesystem.h
     core/src/lib/DFHashTable.c
     core/src/lib/DFHashTable.h
-    core/src/lib/DFPackage.c
-    core/src/lib/DFPackage.h
     core/src/lib/DFString.c
     core/src/lib/DFString.h
+    core/src/lib/DFStorage.c
+    core/src/lib/DFStorage.h
     core/src/lib/DFZipFile.c
     core/src/lib/DFZipFile.h
     core/tests/lib/LibTests.c)

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/api/headers/DocFormats/Operations.h
----------------------------------------------------------------------
diff --git a/DocFormats/api/headers/DocFormats/Operations.h b/DocFormats/api/headers/DocFormats/Operations.h
index 0cf7cae..40aab83 100644
--- a/DocFormats/api/headers/DocFormats/Operations.h
+++ b/DocFormats/api/headers/DocFormats/Operations.h
@@ -16,7 +16,7 @@
 #define DocFormats_Operations_h
 
 #include "DFError.h"
-#include "DFPackage.h"
+#include "DFStorage.h"
 #include "DFXMLForward.h"
 
 // Abstraction level 2
@@ -24,13 +24,13 @@
 typedef struct DFConcreteDocument DFConcreteDocument;
 typedef struct DFAbstractDocument DFAbstractDocument;
 
-DFConcreteDocument *DFConcreteDocumentNew(DFPackage *package);
+DFConcreteDocument *DFConcreteDocumentNew(DFStorage *storage);
 DFConcreteDocument *DFConcreteDocumentCreateFile(const char *filename, DFError **error);
 DFConcreteDocument *DFConcreteDocumentOpenFile(const char *filename, DFError **error);
 DFConcreteDocument *DFConcreteDocumentRetain(DFConcreteDocument *concrete);
 void DFConcreteDocumentRelease(DFConcreteDocument *concrete);
 
-DFAbstractDocument *DFAbstractDocumentNew(DFPackage *package);
+DFAbstractDocument *DFAbstractDocumentNew(DFStorage *storage);
 DFAbstractDocument *DFAbstractDocumentRetain(DFAbstractDocument *abstract);
 void DFAbstractDocumentRelease(DFAbstractDocument *abstract);
 DFDocument *DFAbstractDocumentGetHTML(DFAbstractDocument *abstract);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/api/src/Operations.c
----------------------------------------------------------------------
diff --git a/DocFormats/api/src/Operations.c b/DocFormats/api/src/Operations.c
index cd4aa12..ae305b0 100644
--- a/DocFormats/api/src/Operations.c
+++ b/DocFormats/api/src/Operations.c
@@ -15,7 +15,7 @@
 #include <DocFormats/Operations.h>
 #include "DFFilesystem.h"
 #include "DFString.h"
-#include "DFPackage.h"
+#include "DFStorage.h"
 #include "Word.h"
 #include "DFHTML.h"
 #include "DFDOM.h"
@@ -25,20 +25,20 @@
 
 struct DFConcreteDocument {
     size_t retainCount;
-    DFPackage *package;
+    DFStorage *storage;
 };
 
 struct DFAbstractDocument {
     size_t retainCount;
-    DFPackage *package;
+    DFStorage *storage;
     DFDocument *htmlDoc;
 };
 
-DFConcreteDocument *DFConcreteDocumentNew(DFPackage *package)
+DFConcreteDocument *DFConcreteDocumentNew(DFStorage *storage)
 {
     DFConcreteDocument *concrete = (DFConcreteDocument *)calloc(1,sizeof(DFConcreteDocument));
     concrete->retainCount = 1;
-    concrete->package = DFPackageRetain(package);
+    concrete->storage = DFStorageRetain(storage);
     return concrete;
 }
 
@@ -52,11 +52,11 @@ DFConcreteDocument *DFConcreteDocumentCreateFile(const char *filename, DFError *
         case DFFileFormatOdt:
         case DFFileFormatOds:
         case DFFileFormatOdp: {
-            DFPackage *package = DFPackageCreateZip(filename,error);
-            if (package == NULL)
+            DFStorage *storage = DFStorageCreateZip(filename,error);
+            if (storage == NULL)
                 return NULL;;
-            DFConcreteDocument *concrete = DFConcreteDocumentNew(package);
-            DFPackageRelease(package);
+            DFConcreteDocument *concrete = DFConcreteDocumentNew(storage);
+            DFStorageRelease(storage);
             return concrete;
         }
         default:
@@ -75,11 +75,11 @@ DFConcreteDocument *DFConcreteDocumentOpenFile(const char *filename, DFError **e
         case DFFileFormatOdt:
         case DFFileFormatOds:
         case DFFileFormatOdp: {
-            DFPackage *package = DFPackageOpenZip(filename,error);
-            if (package == NULL)
+            DFStorage *storage = DFStorageOpenZip(filename,error);
+            if (storage == NULL)
                 return NULL;;
-            DFConcreteDocument *concrete = DFConcreteDocumentNew(package);
-            DFPackageRelease(package);
+            DFConcreteDocument *concrete = DFConcreteDocumentNew(storage);
+            DFStorageRelease(storage);
             return concrete;
         }
         default:
@@ -100,15 +100,15 @@ void DFConcreteDocumentRelease(DFConcreteDocument *concrete)
     if ((concrete == NULL) || (--concrete->retainCount > 0))
         return;
 
-    DFPackageRelease(concrete->package);
+    DFStorageRelease(concrete->storage);
     free(concrete);
 }
 
-DFAbstractDocument *DFAbstractDocumentNew(DFPackage *package)
+DFAbstractDocument *DFAbstractDocumentNew(DFStorage *storage)
 {
     DFAbstractDocument *abstract = (DFAbstractDocument *)calloc(1,sizeof(DFAbstractDocument));
     abstract->retainCount = 1;
-    abstract->package = DFPackageRetain(package);
+    abstract->storage = DFStorageRetain(storage);
     return abstract;
 }
 
@@ -124,7 +124,7 @@ void DFAbstractDocumentRelease(DFAbstractDocument *abstract)
     if ((abstract == NULL) || (--abstract->retainCount > 0))
         return;
 
-    DFPackageRelease(abstract->package);
+    DFStorageRelease(abstract->storage);
     DFDocumentRelease(abstract->htmlDoc);
     free(abstract);
 }
@@ -142,15 +142,15 @@ void DFAbstractDocumentSetHTML(DFAbstractDocument *abstract, DFDocument *htmlDoc
 
 int DFGet(DFConcreteDocument *concrete, DFAbstractDocument *abstract, DFError **error)
 {
-    if (DFPackageFormat(abstract->package) != DFFileFormatHTML) {
+    if (DFStorageFormat(abstract->storage) != DFFileFormatHTML) {
         DFErrorFormat(error,"Abstract document must be in HTML format");
         return 0;
     }
 
     DFDocument *htmlDoc = NULL;
-    switch (DFPackageFormat(concrete->package)) {
+    switch (DFStorageFormat(concrete->storage)) {
         case DFFileFormatDocx:
-            htmlDoc = WordGet(concrete->package,abstract->package,error);
+            htmlDoc = WordGet(concrete->storage,abstract->storage,error);
             break;
         default:
             DFErrorFormat(error,"Unsupported file format");
@@ -167,15 +167,15 @@ int DFGet(DFConcreteDocument *concrete, DFAbstractDocument *abstract, DFError **
 
 int DFPut(DFConcreteDocument *concreteDoc, DFAbstractDocument *abstractDoc, DFError **error)
 {
-    if (DFPackageFormat(abstractDoc->package) != DFFileFormatHTML) {
+    if (DFStorageFormat(abstractDoc->storage) != DFFileFormatHTML) {
         DFErrorFormat(error,"Abstract document must be in HTML format");
         return 0;
     }
 
     int ok = 0;
-    switch (DFPackageFormat(concreteDoc->package)) {
+    switch (DFStorageFormat(concreteDoc->storage)) {
         case DFFileFormatDocx:
-            ok = WordPut(concreteDoc->package,abstractDoc->package,abstractDoc->htmlDoc,error);
+            ok = WordPut(concreteDoc->storage,abstractDoc->storage,abstractDoc->htmlDoc,error);
             break;
         default:
             DFErrorFormat(error,"Unsupported file format");
@@ -186,15 +186,15 @@ int DFPut(DFConcreteDocument *concreteDoc, DFAbstractDocument *abstractDoc, DFEr
 
 int DFCreate(DFConcreteDocument *concreteDoc, DFAbstractDocument *abstractDoc, DFError **error)
 {
-    if (DFPackageFormat(abstractDoc->package) != DFFileFormatHTML) {
+    if (DFStorageFormat(abstractDoc->storage) != DFFileFormatHTML) {
         DFErrorFormat(error,"Abstract document must be in HTML format");
         return 0;
     }
 
     int ok = 0;
-    switch (DFPackageFormat(concreteDoc->package)) {
+    switch (DFStorageFormat(concreteDoc->storage)) {
         case DFFileFormatDocx:
-            ok = WordCreate(concreteDoc->package,abstractDoc->package,abstractDoc->htmlDoc,error);
+            ok = WordCreate(concreteDoc->storage,abstractDoc->storage,abstractDoc->htmlDoc,error);
             break;
         default:
             DFErrorFormat(error,"Unsupported file format");
@@ -207,7 +207,7 @@ int DFGetFile(const char *concreteFilename, const char *abstractFilename, DFErro
 {
     int r = 0;
     char *abstractPath = DFPathDirName(abstractFilename);
-    DFPackage *abstractPackage = DFPackageNewFilesystem(abstractPath,DFFileFormatHTML);
+    DFStorage *abstractStorage = DFStorageNewFilesystem(abstractPath,DFFileFormatHTML);
     DFConcreteDocument *concreteDoc = NULL;
     DFAbstractDocument *abstractDoc = NULL;
 
@@ -217,7 +217,7 @@ int DFGetFile(const char *concreteFilename, const char *abstractFilename, DFErro
         goto end;
     }
 
-    abstractDoc = DFAbstractDocumentNew(abstractPackage);
+    abstractDoc = DFAbstractDocumentNew(abstractStorage);
 
     if (!DFGet(concreteDoc,abstractDoc,error) || (abstractDoc->htmlDoc == NULL)) {
         DFErrorFormat(error,"%s: %s",concreteFilename,DFErrorMessage(error));
@@ -238,7 +238,7 @@ int DFGetFile(const char *concreteFilename, const char *abstractFilename, DFErro
 
 end:
     free(abstractPath);
-    DFPackageRelease(abstractPackage);
+    DFStorageRelease(abstractStorage);
     DFConcreteDocumentRelease(concreteDoc);
     DFAbstractDocumentRelease(abstractDoc);
     return r;
@@ -249,7 +249,7 @@ int DFPutFile(const char *concreteFilename, const char *abstractFilename, DFErro
     int ok = 0;
     DFDocument *htmlDoc2 = NULL;
     char *abstractPath = DFPathDirName(abstractFilename);
-    DFPackage *abstractPackage2 = DFPackageNewFilesystem(abstractPath,DFFileFormatHTML);
+    DFStorage *abstractStorage2 = DFStorageNewFilesystem(abstractPath,DFFileFormatHTML);
     DFConcreteDocument *concreteDoc = NULL;
     DFAbstractDocument *abstractDoc = NULL;
 
@@ -265,7 +265,7 @@ int DFPutFile(const char *concreteFilename, const char *abstractFilename, DFErro
         goto end;
     }
 
-    abstractDoc = DFAbstractDocumentNew(abstractPackage2);
+    abstractDoc = DFAbstractDocumentNew(abstractStorage2);
     abstractDoc->htmlDoc = DFDocumentRetain(htmlDoc2);
 
     ok = DFPut(concreteDoc,abstractDoc,error);
@@ -273,7 +273,7 @@ int DFPutFile(const char *concreteFilename, const char *abstractFilename, DFErro
 end:
     DFDocumentRelease(htmlDoc2);
     free(abstractPath);
-    DFPackageRelease(abstractPackage2);
+    DFStorageRelease(abstractStorage2);
     DFConcreteDocumentRelease(concreteDoc);
     DFAbstractDocumentRelease(abstractDoc);
     return ok;
@@ -284,7 +284,7 @@ int DFCreateFile(const char *concreteFilename, const char *abstractFilename, DFE
     int ok = 0;
     DFDocument *htmlDoc = NULL;
     char *abstractPath = DFPathDirName(abstractFilename);
-    DFPackage *abstractPackage = DFPackageNewFilesystem(abstractPath,DFFileFormatHTML);
+    DFStorage *abstractStorage = DFStorageNewFilesystem(abstractPath,DFFileFormatHTML);
     DFConcreteDocument *concreteDoc = NULL;
     DFAbstractDocument *abstractDoc = NULL;
 
@@ -300,7 +300,7 @@ int DFCreateFile(const char *concreteFilename, const char *abstractFilename, DFE
         goto end;
     }
 
-    abstractDoc = DFAbstractDocumentNew(abstractPackage);
+    abstractDoc = DFAbstractDocumentNew(abstractStorage);
     abstractDoc->htmlDoc = DFDocumentRetain(htmlDoc);
 
     ok = DFCreate(concreteDoc,abstractDoc,error);
@@ -308,7 +308,7 @@ int DFCreateFile(const char *concreteFilename, const char *abstractFilename, DFE
 end:
     DFDocumentRelease(htmlDoc);
     free(abstractPath);
-    DFPackageRelease(abstractPackage);
+    DFStorageRelease(abstractStorage);
     DFConcreteDocumentRelease(concreteDoc);
     DFAbstractDocumentRelease(abstractDoc);
     return ok;

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/core/src/lib/DFBuffer.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFBuffer.c b/DocFormats/core/src/lib/DFBuffer.c
index f542fc4..19b67c3 100644
--- a/DocFormats/core/src/lib/DFBuffer.c
+++ b/DocFormats/core/src/lib/DFBuffer.c
@@ -132,11 +132,11 @@ DFBuffer *DFBufferReadFromFile(const char *filename, DFError **error)
     return buf;
 }
 
-DFBuffer *DFBufferReadFromPackage(DFPackage *package, const char *filename, DFError **error)
+DFBuffer *DFBufferReadFromStorage(DFStorage *storage, const char *filename, DFError **error)
 {
     void *data = 0;
     size_t len = 0;
-    if (!DFPackageRead(package,filename,&data,&len,error))
+    if (!DFStorageRead(storage,filename,&data,&len,error))
         return NULL;;
     DFBuffer *r = DFBufferNew();;
     DFBufferAppendData(r,data,len);
@@ -144,9 +144,9 @@ DFBuffer *DFBufferReadFromPackage(DFPackage *package, const char *filename, DFEr
     return r;
 }
 
-int DFBufferWriteToPackage(DFBuffer *buf, DFPackage *package, const char *filename, DFError **error)
+int DFBufferWriteToStorage(DFBuffer *buf, DFStorage *storage, const char *filename, DFError **error)
 {
-    return DFPackageWrite(package,filename,buf->data,buf->len,error);
+    return DFStorageWrite(storage,filename,buf->data,buf->len,error);
 }
 
 int DFBufferWriteToFile(DFBuffer *buf, const char *filename, DFError **error)

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/core/src/lib/DFBuffer.h
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFBuffer.h b/DocFormats/core/src/lib/DFBuffer.h
index 5414d8a..ca739fe 100644
--- a/DocFormats/core/src/lib/DFBuffer.h
+++ b/DocFormats/core/src/lib/DFBuffer.h
@@ -17,7 +17,7 @@
 
 #include "DFError.h"
 #include "DFTypes.h"
-#include "DFPackage.h"
+#include "DFStorage.h"
 #include <stdarg.h>
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -45,9 +45,9 @@ void DFBufferAppendChar(DFBuffer *buf, char ch);
 void DFBufferVFormat(DFBuffer *buf, const char *format, va_list ap);
 void DFBufferFormat(DFBuffer *buf, const char *format, ...) ATTRIBUTE_FORMAT(printf,2,3);
 DFBuffer *DFBufferReadFromFile(const char *filename, DFError **error);
-DFBuffer *DFBufferReadFromPackage(DFPackage *package, const char *filename, DFError **error);
+DFBuffer *DFBufferReadFromStorage(DFStorage *storage, const char *filename, DFError **error);
 int DFBufferWriteToFile(DFBuffer *buf, const char *filename, DFError **error);
-int DFBufferWriteToPackage(DFBuffer *buf, DFPackage *package, const char *filename, DFError **error);
+int DFBufferWriteToStorage(DFBuffer *buf, DFStorage *storage, const char *filename, DFError **error);
 
 int DFWriteDataToFile(const void *data, size_t len, const char *filename, DFError **error);
 

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/core/src/lib/DFPackage.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFPackage.c b/DocFormats/core/src/lib/DFPackage.c
deleted file mode 100644
index 3024b3c..0000000
--- a/DocFormats/core/src/lib/DFPackage.c
+++ /dev/null
@@ -1,440 +0,0 @@
-// Copyright 2012-2014 UX Productivity Pty Ltd
-//
-// Licensed 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 "DFPackage.h"
-#include "DFCommon.h"
-#include "DFString.h"
-#include "DFFilesystem.h"
-#include "DFBuffer.h"
-#include "DFZipFile.h"
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-typedef struct DFPackageOps DFPackageOps;
-
-struct DFPackageOps {
-    int (*save)(DFPackage *package, DFError **error);
-    int (*read)(DFPackage *package, const char *path, void **buf, size_t *nbytes, DFError **error);
-    int (*write)(DFPackage *package, const char *path, void *buf, size_t nbytes, DFError **error);
-    int (*exists)(DFPackage *package, const char *path);
-    int (*delete)(DFPackage *package, const char *path, DFError **error);
-    const char **(*list)(DFPackage *package, DFError **error);
-};
-
-struct DFPackage {
-    size_t retainCount;
-    DFFileFormat format;
-    char *rootPath;
-    char *zipFilename;
-    DFHashTable *files;
-    const DFPackageOps *ops;
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-//                                                                                                //
-//                                     DFPackage (Filesystem)                                     //
-//                                                                                                //
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-static int fsSave(DFPackage *package, DFError **error)
-{
-    // Nothing to do here; we've already written everything to the filesystem
-    // at the time the calls were made.
-    return 1;
-}
-
-static int fsRead(DFPackage *package, const char *path, void **buf, size_t *nbytes, DFError **error)
-{
-    char *fullPath = DFAppendPathComponent(package->rootPath,path);
-    int ok = 0;
-
-    FILE *file = fopen(fullPath,"rb");
-    if (file == NULL) {
-        DFErrorSetPosix(error,errno);
-        goto end;
-    }
-
-    size_t balloc = 4096;
-    size_t blen = 0;
-    char *mem = (char *)malloc(balloc);
-
-    size_t r;
-    while (0 < (r = fread(&mem[blen],1,4096,file))) {
-        balloc += r;
-        blen += r;
-        mem = (char *)realloc(mem,balloc);
-    }
-    ok = 1;
-
-    *buf = mem;
-    *nbytes = blen;
-
-end:
-    if (file != NULL)
-        fclose(file);
-    free(fullPath);
-    return ok;
-}
-
-static int fsWrite(DFPackage *package, const char *path, void *buf, size_t nbytes, DFError **error)
-{
-    char *fullPath = DFAppendPathComponent(package->rootPath,path);
-    char *parentPath = DFPathDirName(fullPath);
-    int r = 0;
-    FILE *file = NULL;
-
-    if (!DFFileExists(parentPath) && !DFCreateDirectory(parentPath,1,error))
-        goto end;
-
-    file = fopen(fullPath,"wb");
-    if (file == NULL) {
-        DFErrorSetPosix(error,errno);
-        goto end;
-    }
-    size_t w = fwrite(buf,1,nbytes,file);
-    if (w != nbytes) {
-        DFErrorFormat(error,"Incomplete write");
-        goto end;
-    }
-    r = 1;
-
-end:
-    if (file != NULL)
-        fclose(file);
-    free(parentPath);
-    free(fullPath);
-    return r;
-}
-
-static int fsExists(DFPackage *package, const char *path)
-{
-    char *fullPath = DFAppendPathComponent(package->rootPath,path);
-    int r = DFFileExists(fullPath);
-    free(fullPath);
-    return r;
-}
-
-static int fsDelete(DFPackage *package, const char *path, DFError **error)
-{
-    char *fullPath = DFAppendPathComponent(package->rootPath,path);
-    int r = DFDeleteFile(fullPath,error);
-    free(fullPath);
-    return r;
-}
-
-const char **fsList(DFPackage *package, DFError **error)
-{
-    const char **allPaths = DFContentsOfDirectory(package->rootPath,1,error);
-    if (allPaths == NULL)
-        return NULL;;
-
-    DFArray *filesOnly = DFArrayNew((DFCopyFunction)strdup,(DFFreeFunction)free);
-    for (int i = 0; allPaths[i]; i++) {
-        const char *relPath = allPaths[i];
-        char *absPath = DFAppendPathComponent(package->rootPath,relPath);
-        if (!DFIsDirectory(absPath))
-            DFArrayAppend(filesOnly,(void *)relPath);
-        free(absPath);
-    }
-
-    const char **result = DFStringArrayFlatten(filesOnly);
-    DFArrayRelease(filesOnly);
-    free(allPaths);
-    return result;
-}
-
-static DFPackageOps fsOps = {
-    .save = fsSave,
-    .read = fsRead,
-    .write = fsWrite,
-    .exists = fsExists,
-    .delete = fsDelete,
-    .list = fsList,
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-//                                                                                                //
-//                                       DFPackage (Memory)                                       //
-//                                                                                                //
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-static int memSave(DFPackage *package, DFError **error)
-{
-    // Nothing to do here; memory packages are intended to be temporary, and are never saved to disk
-    return 1;
-}
-
-static int memRead(DFPackage *package, const char *path, void **buf, size_t *nbytes, DFError **error)
-{
-    DFBuffer *buffer = DFHashTableLookup(package->files,path);
-    if (buffer == NULL) {
-        DFErrorSetPosix(error,ENOENT);
-        return 0;
-    }
-
-    *buf = malloc(buffer->len);
-    memcpy(*buf,buffer->data,buffer->len);
-    *nbytes = buffer->len;
-
-    return 1;
-}
-
-static int memWrite(DFPackage *package, const char *path, void *buf, size_t nbytes, DFError **error)
-{
-    DFBuffer *buffer = DFBufferNew();
-    DFBufferAppendData(buffer,buf,nbytes);
-    DFHashTableAdd(package->files,path,buffer);
-    DFBufferRelease(buffer);
-    return 1;
-}
-
-static int memExists(DFPackage *package, const char *path)
-{
-    return (DFHashTableLookup(package->files,path) != NULL);
-}
-
-static int memDelete(DFPackage *package, const char *path, DFError **error)
-{
-    DFHashTableRemove(package->files,path);
-    return 1;
-}
-
-static const char **memList(DFPackage *package, DFError **error)
-{
-    return DFHashTableCopyKeys(package->files);
-}
-
-static DFPackageOps memOps = {
-    .save = memSave,
-    .read = memRead,
-    .write = memWrite,
-    .exists = memExists,
-    .delete = memDelete,
-    .list = memList,
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-//                                                                                                //
-//                                         DFPackage (Zip)                                        //
-//                                                                                                //
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-// Currently, zip packages operate just like memory packages, in that they store their contents in
-// a hash table. The only difference is that they extract all the entries from a zip file on
-// creation, and overwrite the zip file on save.
-//
-// Eventually, we should make it so the entries are read on-demand, and also that a new, temporary
-// zip file is written if the package is modified, and that new version replaces the existing one on
-// save.
-
-static int zipSave(DFPackage *package, DFError **error)
-{
-    return DFZip(package->zipFilename,package,error);
-}
-
-static int zipRead(DFPackage *package, const char *path, void **buf, size_t *nbytes, DFError **error)
-{
-    DFBuffer *buffer = DFHashTableLookup(package->files,path);
-    if (buffer == NULL) {
-        DFErrorSetPosix(error,ENOENT);
-        return 0;
-    }
-
-    *buf = malloc(buffer->len);
-    memcpy(*buf,buffer->data,buffer->len);
-    *nbytes = buffer->len;
-
-    return 1;
-}
-
-static int zipWrite(DFPackage *package, const char *path, void *buf, size_t nbytes, DFError **error)
-{
-    DFBuffer *buffer = DFBufferNew();
-    DFBufferAppendData(buffer,buf,nbytes);
-    DFHashTableAdd(package->files,path,buffer);
-    DFBufferRelease(buffer);
-    return 1;
-}
-
-static int zipExists(DFPackage *package, const char *path)
-{
-    return (DFHashTableLookup(package->files,path) != NULL);
-}
-
-static int zipDelete(DFPackage *package, const char *path, DFError **error)
-{
-    DFHashTableRemove(package->files,path);
-    return 1;
-}
-
-static const char **zipList(DFPackage *package, DFError **error)
-{
-    return DFHashTableCopyKeys(package->files);
-}
-
-static DFPackageOps zipOps = {
-    .save = zipSave,
-    .read = zipRead,
-    .write = zipWrite,
-    .exists = zipExists,
-    .delete = zipDelete,
-    .list = zipList,
-};
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-//                                                                                                //
-//                                            DFPackage                                           //
-//                                                                                                //
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-// Normalize the path to remove multiple consecutive / characters, and to remove any trailing /
-// character. This ensures that for implementations which rely on an exact match of the path
-// (specifically, the memory package), that any non-essential differences in the supplied path will
-// not matter.
-
-static char *fixPath(const char *input)
-{
-    char *normalized = DFPathNormalize(input);
-    char *result;
-    if (normalized[0] == '/')
-        result = strdup(&normalized[1]);
-    else
-        result = strdup(normalized);
-    free(normalized);
-    return result;
-}
-
-static DFPackage *DFPackageNew(DFFileFormat format, const DFPackageOps *ops)
-{
-    DFPackage *package = (DFPackage *)calloc(1,sizeof(DFPackage));
-    package->retainCount = 1;
-    package->format = format;
-    package->ops = ops;
-    return package;
-}
-
-DFPackage *DFPackageNewFilesystem(const char *rootPath, DFFileFormat format)
-{
-    if ((rootPath == NULL) || (strlen(rootPath) == 0))
-        rootPath = ".";;
-    DFPackage *package = DFPackageNew(format,&fsOps);
-    package->rootPath = strdup(rootPath);
-    return package;
-}
-
-DFPackage *DFPackageNewMemory(DFFileFormat format)
-{
-    DFPackage *package = DFPackageNew(format,&memOps);
-    package->files = DFHashTableNew((DFCopyFunction)DFBufferRetain,(DFFreeFunction)DFBufferRelease);
-    return package;
-}
-
-DFPackage *DFPackageCreateZip(const char *filename, DFError **error)
-{
-    // Note that with the current implementation, the file doesn't actually get saved until we do a DFPackageSave.
-    if (DFFileExists(filename)) {
-        DFErrorFormat(error,"File already exists");
-        return NULL;
-    }
-
-    DFPackage *package = DFPackageNew(DFFileFormatFromFilename(filename),&zipOps);
-    package->files = DFHashTableNew((DFCopyFunction)DFBufferRetain,(DFFreeFunction)DFBufferRelease);
-    package->zipFilename = strdup(filename);
-    return package;
-}
-
-DFPackage *DFPackageOpenZip(const char *filename, DFError **error)
-{
-    if (!DFFileExists(filename)) {
-        DFErrorFormat(error,"File does not exist");
-        return NULL;
-    }
-
-    DFPackage *package = DFPackageNew(DFFileFormatFromFilename(filename),&zipOps);
-    package->files = DFHashTableNew((DFCopyFunction)DFBufferRetain,(DFFreeFunction)DFBufferRelease);
-    package->zipFilename = strdup(filename);
-
-    if (!DFUnzip(filename,package,error)) {
-        DFPackageRelease(package);
-        return NULL;
-    }
-    return package;
-}
-
-DFPackage *DFPackageRetain(DFPackage *package)
-{
-    if (package != NULL)
-        package->retainCount++;
-    return package;
-}
-
-void DFPackageRelease(DFPackage *package)
-{
-    if ((package == NULL) || (--package->retainCount > 0))
-        return;
-
-    DFHashTableRelease(package->files);
-    free(package->rootPath);
-    free(package->zipFilename);
-    free(package);
-}
-
-DFFileFormat DFPackageFormat(DFPackage *package)
-{
-    return package->format;
-}
-
-int DFPackageSave(DFPackage *package, DFError **error)
-{
-    return package->ops->save(package,error);
-}
-
-int DFPackageRead(DFPackage *package, const char *path, void **buf, size_t *nbytes, DFError **error)
-{
-    char *fixed = fixPath(path);
-    int r = package->ops->read(package,fixed,buf,nbytes,error);
-    free(fixed);
-    return r;
-}
-
-int DFPackageWrite(DFPackage *package, const char *path, void *buf, size_t nbytes, DFError **error)
-{
-    char *fixed = fixPath(path);
-    int r = package->ops->write(package,fixed,buf,nbytes,error);
-    free(fixed);
-    return r;
-}
-
-int DFPackageExists(DFPackage *package, const char *path)
-{
-    char *fixed = fixPath(path);
-    int r = package->ops->exists(package,fixed);
-    free(fixed);
-    return r;
-}
-
-int DFPackageDelete(DFPackage *package, const char *path, DFError **error)
-{
-    char *fixed = fixPath(path);
-    int r = package->ops->delete(package,fixed,error);
-    free(fixed);
-    return r;
-}
-
-const char **DFPackageList(DFPackage *package, DFError **error)
-{
-    return package->ops->list(package,error);
-}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/core/src/lib/DFPackage.h
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFPackage.h b/DocFormats/core/src/lib/DFPackage.h
deleted file mode 100644
index cb02c55..0000000
--- a/DocFormats/core/src/lib/DFPackage.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2012-2014 UX Productivity Pty Ltd
-//
-// Licensed 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.
-
-#ifndef DocFormats_DFPackage_h
-#define DocFormats_DFPackage_h
-
-#include "DFError.h"
-#include "DFTypes.h"
-#include <DocFormats/Formats.h>
-
-typedef struct DFPackage DFPackage;
-
-DFPackage *DFPackageNewFilesystem(const char *rootPath, DFFileFormat format);
-DFPackage *DFPackageNewMemory(DFFileFormat format);
-DFPackage *DFPackageCreateZip(const char *filename, DFError **error);
-DFPackage *DFPackageOpenZip(const char *filename, DFError **error);
-DFPackage *DFPackageRetain(DFPackage *package);
-void DFPackageRelease(DFPackage *package);
-DFFileFormat DFPackageFormat(DFPackage *package);
-int DFPackageSave(DFPackage *package, DFError **error);
-
-int DFPackageRead(DFPackage *package, const char *path, void **buf, size_t *nbytes, DFError **error);
-int DFPackageWrite(DFPackage *package, const char *path, void *buf, size_t nbytes, DFError **error);
-int DFPackageExists(DFPackage *package, const char *path);
-int DFPackageDelete(DFPackage *package, const char *path, DFError **error);
-const char **DFPackageList(DFPackage *package, DFError **error);
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/core/src/lib/DFStorage.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFStorage.c b/DocFormats/core/src/lib/DFStorage.c
new file mode 100644
index 0000000..67a0b2d
--- /dev/null
+++ b/DocFormats/core/src/lib/DFStorage.c
@@ -0,0 +1,441 @@
+// Copyright 2012-2014 UX Productivity Pty Ltd
+//
+// Licensed 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 "DFStorage.h"
+#include "DFCommon.h"
+#include "DFString.h"
+#include "DFFilesystem.h"
+#include "DFBuffer.h"
+#include "DFZipFile.h"
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct DFStorageOps DFStorageOps;
+
+struct DFStorageOps {
+    int (*save)(DFStorage *storage, DFError **error);
+    int (*read)(DFStorage *storage, const char *path, void **buf, size_t *nbytes, DFError **error);
+    int (*write)(DFStorage *storage, const char *path, void *buf, size_t nbytes, DFError **error);
+    int (*exists)(DFStorage *storage, const char *path);
+    int (*delete)(DFStorage *storage, const char *path, DFError **error);
+    const char **(*list)(DFStorage *storage, DFError **error);
+};
+
+struct DFStorage {
+    size_t retainCount;
+    DFFileFormat format;
+    char *rootPath;
+    char *zipFilename;
+    DFHashTable *files;
+    const DFStorageOps *ops;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                     DFStorage (Filesystem)                                     //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static int fsSave(DFStorage *storage, DFError **error)
+{
+    // Nothing to do here; we've already written everything to the filesystem
+    // at the time the calls were made.
+    return 1;
+}
+
+static int fsRead(DFStorage *storage, const char *path, void **buf, size_t *nbytes, DFError **error)
+{
+    char *fullPath = DFAppendPathComponent(storage->rootPath,path);
+    int ok = 0;
+
+    FILE *file = fopen(fullPath,"rb");
+    if (file == NULL) {
+        DFErrorSetPosix(error,errno);
+        goto end;
+    }
+
+    size_t balloc = 4096;
+    size_t blen = 0;
+    char *mem = (char *)malloc(balloc);
+
+    size_t r;
+    while (0 < (r = fread(&mem[blen],1,4096,file))) {
+        balloc += r;
+        blen += r;
+        mem = (char *)realloc(mem,balloc);
+    }
+    ok = 1;
+
+    *buf = mem;
+    *nbytes = blen;
+
+end:
+    if (file != NULL)
+        fclose(file);
+    free(fullPath);
+    return ok;
+}
+
+static int fsWrite(DFStorage *storage, const char *path, void *buf, size_t nbytes, DFError **error)
+{
+    char *fullPath = DFAppendPathComponent(storage->rootPath,path);
+    char *parentPath = DFPathDirName(fullPath);
+    int r = 0;
+    FILE *file = NULL;
+
+    if (!DFFileExists(parentPath) && !DFCreateDirectory(parentPath,1,error))
+        goto end;
+
+    file = fopen(fullPath,"wb");
+    if (file == NULL) {
+        DFErrorSetPosix(error,errno);
+        goto end;
+    }
+    size_t w = fwrite(buf,1,nbytes,file);
+    if (w != nbytes) {
+        DFErrorFormat(error,"Incomplete write");
+        goto end;
+    }
+    r = 1;
+
+end:
+    if (file != NULL)
+        fclose(file);
+    free(parentPath);
+    free(fullPath);
+    return r;
+}
+
+static int fsExists(DFStorage *storage, const char *path)
+{
+    char *fullPath = DFAppendPathComponent(storage->rootPath,path);
+    int r = DFFileExists(fullPath);
+    free(fullPath);
+    return r;
+}
+
+static int fsDelete(DFStorage *storage, const char *path, DFError **error)
+{
+    char *fullPath = DFAppendPathComponent(storage->rootPath,path);
+    int r = DFDeleteFile(fullPath,error);
+    free(fullPath);
+    return r;
+}
+
+const char **fsList(DFStorage *storage, DFError **error)
+{
+    const char **allPaths = DFContentsOfDirectory(storage->rootPath,1,error);
+    if (allPaths == NULL)
+        return NULL;;
+
+    DFArray *filesOnly = DFArrayNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+    for (int i = 0; allPaths[i]; i++) {
+        const char *relPath = allPaths[i];
+        char *absPath = DFAppendPathComponent(storage->rootPath,relPath);
+        if (!DFIsDirectory(absPath))
+            DFArrayAppend(filesOnly,(void *)relPath);
+        free(absPath);
+    }
+
+    const char **result = DFStringArrayFlatten(filesOnly);
+    DFArrayRelease(filesOnly);
+    free(allPaths);
+    return result;
+}
+
+static DFStorageOps fsOps = {
+    .save = fsSave,
+    .read = fsRead,
+    .write = fsWrite,
+    .exists = fsExists,
+    .delete = fsDelete,
+    .list = fsList,
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                       DFStorage (Memory)                                       //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static int memSave(DFStorage *storage, DFError **error)
+{
+    // Nothing to do here; memory-backed storage objects are intended to be temporary, and are never
+    // saved to disk
+    return 1;
+}
+
+static int memRead(DFStorage *storage, const char *path, void **buf, size_t *nbytes, DFError **error)
+{
+    DFBuffer *buffer = DFHashTableLookup(storage->files,path);
+    if (buffer == NULL) {
+        DFErrorSetPosix(error,ENOENT);
+        return 0;
+    }
+
+    *buf = malloc(buffer->len);
+    memcpy(*buf,buffer->data,buffer->len);
+    *nbytes = buffer->len;
+
+    return 1;
+}
+
+static int memWrite(DFStorage *storage, const char *path, void *buf, size_t nbytes, DFError **error)
+{
+    DFBuffer *buffer = DFBufferNew();
+    DFBufferAppendData(buffer,buf,nbytes);
+    DFHashTableAdd(storage->files,path,buffer);
+    DFBufferRelease(buffer);
+    return 1;
+}
+
+static int memExists(DFStorage *storage, const char *path)
+{
+    return (DFHashTableLookup(storage->files,path) != NULL);
+}
+
+static int memDelete(DFStorage *storage, const char *path, DFError **error)
+{
+    DFHashTableRemove(storage->files,path);
+    return 1;
+}
+
+static const char **memList(DFStorage *storage, DFError **error)
+{
+    return DFHashTableCopyKeys(storage->files);
+}
+
+static DFStorageOps memOps = {
+    .save = memSave,
+    .read = memRead,
+    .write = memWrite,
+    .exists = memExists,
+    .delete = memDelete,
+    .list = memList,
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                         DFStorage (Zip)                                        //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// Currently, zip storage objects operate just like memory storage objects, in that they store their
+// contents in a hash table. The only difference is that they extract all the entries from a zip
+// file on creation, and overwrite the zip file on save.
+//
+// Eventually, we should make it so the entries are read on-demand, and also that a new, temporary
+// zip file is written if the storage is modified, and that new version replaces the existing one on
+// save.
+
+static int zipSave(DFStorage *storage, DFError **error)
+{
+    return DFZip(storage->zipFilename,storage,error);
+}
+
+static int zipRead(DFStorage *storage, const char *path, void **buf, size_t *nbytes, DFError **error)
+{
+    DFBuffer *buffer = DFHashTableLookup(storage->files,path);
+    if (buffer == NULL) {
+        DFErrorSetPosix(error,ENOENT);
+        return 0;
+    }
+
+    *buf = malloc(buffer->len);
+    memcpy(*buf,buffer->data,buffer->len);
+    *nbytes = buffer->len;
+
+    return 1;
+}
+
+static int zipWrite(DFStorage *storage, const char *path, void *buf, size_t nbytes, DFError **error)
+{
+    DFBuffer *buffer = DFBufferNew();
+    DFBufferAppendData(buffer,buf,nbytes);
+    DFHashTableAdd(storage->files,path,buffer);
+    DFBufferRelease(buffer);
+    return 1;
+}
+
+static int zipExists(DFStorage *storage, const char *path)
+{
+    return (DFHashTableLookup(storage->files,path) != NULL);
+}
+
+static int zipDelete(DFStorage *storage, const char *path, DFError **error)
+{
+    DFHashTableRemove(storage->files,path);
+    return 1;
+}
+
+static const char **zipList(DFStorage *storage, DFError **error)
+{
+    return DFHashTableCopyKeys(storage->files);
+}
+
+static DFStorageOps zipOps = {
+    .save = zipSave,
+    .read = zipRead,
+    .write = zipWrite,
+    .exists = zipExists,
+    .delete = zipDelete,
+    .list = zipList,
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//                                                                                                //
+//                                            DFStorage                                           //
+//                                                                                                //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// Normalize the path to remove multiple consecutive / characters, and to remove any trailing /
+// character. This ensures that for implementations which rely on an exact match of the path
+// (specifically, the memory storage object), that any non-essential differences in the supplied
+// path will not matter.
+
+static char *fixPath(const char *input)
+{
+    char *normalized = DFPathNormalize(input);
+    char *result;
+    if (normalized[0] == '/')
+        result = strdup(&normalized[1]);
+    else
+        result = strdup(normalized);
+    free(normalized);
+    return result;
+}
+
+static DFStorage *DFStorageNew(DFFileFormat format, const DFStorageOps *ops)
+{
+    DFStorage *storage = (DFStorage *)calloc(1,sizeof(DFStorage));
+    storage->retainCount = 1;
+    storage->format = format;
+    storage->ops = ops;
+    return storage;
+}
+
+DFStorage *DFStorageNewFilesystem(const char *rootPath, DFFileFormat format)
+{
+    if ((rootPath == NULL) || (strlen(rootPath) == 0))
+        rootPath = ".";;
+    DFStorage *storage = DFStorageNew(format,&fsOps);
+    storage->rootPath = strdup(rootPath);
+    return storage;
+}
+
+DFStorage *DFStorageNewMemory(DFFileFormat format)
+{
+    DFStorage *storage = DFStorageNew(format,&memOps);
+    storage->files = DFHashTableNew((DFCopyFunction)DFBufferRetain,(DFFreeFunction)DFBufferRelease);
+    return storage;
+}
+
+DFStorage *DFStorageCreateZip(const char *filename, DFError **error)
+{
+    // Note that with the current implementation, the file doesn't actually get saved until we do a DFStorageSave.
+    if (DFFileExists(filename)) {
+        DFErrorFormat(error,"File already exists");
+        return NULL;
+    }
+
+    DFStorage *storage = DFStorageNew(DFFileFormatFromFilename(filename),&zipOps);
+    storage->files = DFHashTableNew((DFCopyFunction)DFBufferRetain,(DFFreeFunction)DFBufferRelease);
+    storage->zipFilename = strdup(filename);
+    return storage;
+}
+
+DFStorage *DFStorageOpenZip(const char *filename, DFError **error)
+{
+    if (!DFFileExists(filename)) {
+        DFErrorFormat(error,"File does not exist");
+        return NULL;
+    }
+
+    DFStorage *storage = DFStorageNew(DFFileFormatFromFilename(filename),&zipOps);
+    storage->files = DFHashTableNew((DFCopyFunction)DFBufferRetain,(DFFreeFunction)DFBufferRelease);
+    storage->zipFilename = strdup(filename);
+
+    if (!DFUnzip(filename,storage,error)) {
+        DFStorageRelease(storage);
+        return NULL;
+    }
+    return storage;
+}
+
+DFStorage *DFStorageRetain(DFStorage *storage)
+{
+    if (storage != NULL)
+        storage->retainCount++;
+    return storage;
+}
+
+void DFStorageRelease(DFStorage *storage)
+{
+    if ((storage == NULL) || (--storage->retainCount > 0))
+        return;
+
+    DFHashTableRelease(storage->files);
+    free(storage->rootPath);
+    free(storage->zipFilename);
+    free(storage);
+}
+
+DFFileFormat DFStorageFormat(DFStorage *storage)
+{
+    return storage->format;
+}
+
+int DFStorageSave(DFStorage *storage, DFError **error)
+{
+    return storage->ops->save(storage,error);
+}
+
+int DFStorageRead(DFStorage *storage, const char *path, void **buf, size_t *nbytes, DFError **error)
+{
+    char *fixed = fixPath(path);
+    int r = storage->ops->read(storage,fixed,buf,nbytes,error);
+    free(fixed);
+    return r;
+}
+
+int DFStorageWrite(DFStorage *storage, const char *path, void *buf, size_t nbytes, DFError **error)
+{
+    char *fixed = fixPath(path);
+    int r = storage->ops->write(storage,fixed,buf,nbytes,error);
+    free(fixed);
+    return r;
+}
+
+int DFStorageExists(DFStorage *storage, const char *path)
+{
+    char *fixed = fixPath(path);
+    int r = storage->ops->exists(storage,fixed);
+    free(fixed);
+    return r;
+}
+
+int DFStorageDelete(DFStorage *storage, const char *path, DFError **error)
+{
+    char *fixed = fixPath(path);
+    int r = storage->ops->delete(storage,fixed,error);
+    free(fixed);
+    return r;
+}
+
+const char **DFStorageList(DFStorage *storage, DFError **error)
+{
+    return storage->ops->list(storage,error);
+}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/core/src/lib/DFStorage.h
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFStorage.h b/DocFormats/core/src/lib/DFStorage.h
new file mode 100644
index 0000000..9ef9a6a
--- /dev/null
+++ b/DocFormats/core/src/lib/DFStorage.h
@@ -0,0 +1,39 @@
+// Copyright 2012-2014 UX Productivity Pty Ltd
+//
+// Licensed 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.
+
+#ifndef DocFormats_DFStorage_h
+#define DocFormats_DFStorage_h
+
+#include "DFError.h"
+#include "DFTypes.h"
+#include <DocFormats/Formats.h>
+
+typedef struct DFStorage DFStorage;
+
+DFStorage *DFStorageNewFilesystem(const char *rootPath, DFFileFormat format);
+DFStorage *DFStorageNewMemory(DFFileFormat format);
+DFStorage *DFStorageCreateZip(const char *filename, DFError **error);
+DFStorage *DFStorageOpenZip(const char *filename, DFError **error);
+DFStorage *DFStorageRetain(DFStorage *storage);
+void DFStorageRelease(DFStorage *storage);
+DFFileFormat DFStorageFormat(DFStorage *storage);
+int DFStorageSave(DFStorage *storage, DFError **error);
+
+int DFStorageRead(DFStorage *storage, const char *path, void **buf, size_t *nbytes, DFError **error);
+int DFStorageWrite(DFStorage *storage, const char *path, void *buf, size_t nbytes, DFError **error);
+int DFStorageExists(DFStorage *storage, const char *path);
+int DFStorageDelete(DFStorage *storage, const char *path, DFError **error);
+const char **DFStorageList(DFStorage *storage, DFError **error);
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/core/src/lib/DFZipFile.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFZipFile.c b/DocFormats/core/src/lib/DFZipFile.c
index 41c3cc1..651b43b 100644
--- a/DocFormats/core/src/lib/DFZipFile.c
+++ b/DocFormats/core/src/lib/DFZipFile.c
@@ -33,7 +33,7 @@ static int zipError(DFError **error, const char *format, ...)
     return 0;
 }
 
-int DFUnzip(const char *zipFilename, DFPackage *package, DFError **error)
+int DFUnzip(const char *zipFilename, DFStorage *storage, DFError **error)
 {
     unzFile zipFile = unzOpen(zipFilename);
     if (zipFile == NULL)
@@ -67,7 +67,7 @@ int DFUnzip(const char *zipFilename, DFPackage *package, DFError **error)
                 return zipError(error,"%s: decompression failed",entryName);
             }
 
-            if (!DFBufferWriteToPackage(content,package,entryName,error)) {
+            if (!DFBufferWriteToStorage(content,storage,entryName,error)) {
                 DFBufferRelease(content);
                 return zipError(error,"%s: %s",entryName,DFErrorMessage(error));
             }
@@ -110,14 +110,14 @@ static int zipAddFile(zipFile zip, const char *dest, DFBuffer *content, DFError
     return 1;
 }
 
-int DFZip(const char *zipFilename, DFPackage *package, DFError **error)
+int DFZip(const char *zipFilename, DFStorage *storage, DFError **error)
 {
     const char **allPaths = NULL;
     zipFile zip = NULL;
     DFBuffer *content = NULL;
     int ok = 0;
 
-    allPaths = DFPackageList(package,error);
+    allPaths = DFStorageList(storage,error);
     if (allPaths == NULL)
         goto end;
 
@@ -131,7 +131,7 @@ int DFZip(const char *zipFilename, DFPackage *package, DFError **error)
         const char *path = allPaths[i];
 
         DFBufferRelease(content);
-        content = DFBufferReadFromPackage(package,path,error);
+        content = DFBufferReadFromStorage(storage,path,error);
         if (content == NULL) {
             DFErrorFormat(error,"%s: %s",path,DFErrorMessage(error));
             goto end;

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/core/src/lib/DFZipFile.h
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/lib/DFZipFile.h b/DocFormats/core/src/lib/DFZipFile.h
index 4f4644e..21b5041 100644
--- a/DocFormats/core/src/lib/DFZipFile.h
+++ b/DocFormats/core/src/lib/DFZipFile.h
@@ -16,9 +16,9 @@
 #define DocFormats_DFZipFile_h
 
 #include "DFError.h"
-#include "DFPackage.h"
+#include "DFStorage.h"
 
-int DFUnzip(const char *zipFilename, DFPackage *package, DFError **error);
-int DFZip(const char *zipFilename, DFPackage *package, DFError **error);
+int DFUnzip(const char *zipFilename, DFStorage *storage, DFError **error);
+int DFZip(const char *zipFilename, DFStorage *storage, DFError **error);
 
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/core/src/xml/DFXML.c
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/xml/DFXML.c b/DocFormats/core/src/xml/DFXML.c
index bbd0204..cf9a4f4 100644
--- a/DocFormats/core/src/xml/DFXML.c
+++ b/DocFormats/core/src/xml/DFXML.c
@@ -556,9 +556,9 @@ DFDocument *DFParseXMLFile(const char *filename, DFError **error)
     return doc;
 }
 
-DFDocument *DFParseXMLPackage(DFPackage *package, const char *filename, DFError **error)
+DFDocument *DFParseXMLStorage(DFStorage *storage, const char *filename, DFError **error)
 {
-    DFBuffer *content = DFBufferReadFromPackage(package,filename,error);
+    DFBuffer *content = DFBufferReadFromStorage(storage,filename,error);
     if (content == NULL)
         return NULL;;
     DFDocument *doc = DFParseXMLString(content->data,error);
@@ -621,14 +621,14 @@ int DFSerializeXMLFile(DFDocument *doc, NamespaceID defaultNS, int indent, const
     return r;
 }
 
-int DFSerializeXMLPackage(DFDocument *doc, NamespaceID defaultNS, int indent,
-                          DFPackage *package, const char *filename,
+int DFSerializeXMLStorage(DFDocument *doc, NamespaceID defaultNS, int indent,
+                          DFStorage *storage, const char *filename,
                           DFError **error)
 {
     char *str = DFSerializeXMLString(doc,defaultNS,indent);
     DFBuffer *content = DFBufferNew();
     DFBufferAppendString(content,str);
-    int r = DFBufferWriteToPackage(content,package,filename,error);
+    int r = DFBufferWriteToStorage(content,storage,filename,error);
     DFBufferRelease(content);
     free(str);
     return r;

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/core/src/xml/DFXML.h
----------------------------------------------------------------------
diff --git a/DocFormats/core/src/xml/DFXML.h b/DocFormats/core/src/xml/DFXML.h
index 91388bd..b57025a 100644
--- a/DocFormats/core/src/xml/DFXML.h
+++ b/DocFormats/core/src/xml/DFXML.h
@@ -20,17 +20,17 @@
 #include "DFXMLForward.h"
 #include "DFError.h"
 #include "DFBuffer.h"
-#include "DFPackage.h"
+#include "DFStorage.h"
 
 DFDocument *DFParseXMLString(const char *str, DFError **error);
 DFDocument *DFParseXMLFile(const char *filename, DFError **error);
-DFDocument *DFParseXMLPackage(DFPackage *package, const char *filename, DFError **error);
+DFDocument *DFParseXMLStorage(DFStorage *storage, const char *filename, DFError **error);
 
 void DFSerializeXMLBuffer(DFDocument *doc, NamespaceID defaultNS, int indent, DFBuffer *buf);
 char *DFSerializeXMLString(DFDocument *doc, NamespaceID defaultNS, int indent);
 int DFSerializeXMLFile(DFDocument *doc, NamespaceID defaultNS, int indent, const char *filename, DFError **error);
-int DFSerializeXMLPackage(DFDocument *doc, NamespaceID defaultNS, int indent,
-                        DFPackage *package, const char *filename,
-                        DFError **error);
+int DFSerializeXMLStorage(DFDocument *doc, NamespaceID defaultNS, int indent,
+                          DFStorage *storage, const char *filename,
+                          DFError **error);
 
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/filters/ooxml/src/common/OPC.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/common/OPC.c b/DocFormats/filters/ooxml/src/common/OPC.c
index 94f7a27..2937645 100644
--- a/DocFormats/filters/ooxml/src/common/OPC.c
+++ b/DocFormats/filters/ooxml/src/common/OPC.c
@@ -251,9 +251,9 @@ static const char *OPCContentTypesTypeForPartName(OPCContentTypes *ct, const cha
     return "";
 }
 
-static int OPCContentTypesLoadFromFile(OPCContentTypes *ct, DFPackage *package, const char *relPath, DFError **error)
+static int OPCContentTypesLoadFromFile(OPCContentTypes *ct, DFStorage *storage, const char *relPath, DFError **error)
 {
-    DFDocument *doc = DFParseXMLPackage(package,relPath,error);
+    DFDocument *doc = DFParseXMLStorage(storage,relPath,error);
     if (doc == NULL) {
         char *filename = DFPathBaseName(relPath);
         DFErrorFormat(error,"%s: %s",filename,DFErrorMessage(error));
@@ -289,7 +289,7 @@ static int OPCContentTypesLoadFromFile(OPCContentTypes *ct, DFPackage *package,
     return 1;
 }
 
-static int OPCContentTypesSaveToFile(OPCContentTypes *ct, DFPackage *package, const char *relPath, DFError **error)
+static int OPCContentTypesSaveToFile(OPCContentTypes *ct, DFStorage *storage, const char *relPath, DFError **error)
 {
     DFDocument *doc = DFDocumentNew();
     DFNode *types = DFCreateElement(doc,CT_TYPES);
@@ -316,7 +316,7 @@ static int OPCContentTypesSaveToFile(OPCContentTypes *ct, DFPackage *package, co
         DFAppendChild(types,override);
     }
     free(keys);
-    if (!DFSerializeXMLPackage(doc,NAMESPACE_CT,0,package,relPath,error)) {
+    if (!DFSerializeXMLStorage(doc,NAMESPACE_CT,0,storage,relPath,error)) {
         char *filename = DFPathBaseName(relPath);
         DFErrorFormat(error,"%s: %s",filename,DFErrorMessage(error));
         free(filename);
@@ -348,10 +348,10 @@ void OPCContentTypesRemoveOverride(OPCContentTypes *ct, const char *partName)
 //                                                                                                //
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
-static OPCPackage *OPCPackageNew(DFPackage *store)
+static OPCPackage *OPCPackageNew(DFStorage *storage)
 {
     OPCPackage *pkg = (OPCPackage *)calloc(1,sizeof(OPCPackage));
-    pkg->store = DFPackageRetain(store);
+    pkg->storage = DFStorageRetain(storage);
     pkg->contentTypes = OPCContentTypesNew();
     pkg->relationships = OPCRelationshipSetNew();
     pkg->partsByName = DFHashTableNew((DFCopyFunction)OPCPartRetain,(DFFreeFunction)OPCPartRelease);
@@ -361,7 +361,7 @@ static OPCPackage *OPCPackageNew(DFPackage *store)
 
 void OPCPackageFree(OPCPackage *pkg)
 {
-    DFPackageRelease(pkg->store);
+    DFStorageRelease(pkg->storage);
     OPCContentTypesFree(pkg->contentTypes);
     OPCRelationshipSetFree(pkg->relationships);
     DFHashTableRelease(pkg->partsByName);
@@ -405,7 +405,7 @@ static void saveRelationships(OPCPackage *pkg, OPCRelationshipSet *rels, const c
 
     if (idCount == 0) {
         DFError *error = NULL;
-        if (DFPackageExists(pkg->store,relativePath) && !DFPackageDelete(pkg->store,relativePath,&error)) {
+        if (DFStorageExists(pkg->storage,relativePath) && !DFStorageDelete(pkg->storage,relativePath,&error)) {
             OPCPackageError(pkg,"%s: %s",relativePath,DFErrorMessage(&error));
             DFErrorRelease(error);
         }
@@ -413,7 +413,7 @@ static void saveRelationships(OPCPackage *pkg, OPCRelationshipSet *rels, const c
     else {
         DFError *error = NULL;
         DFDocument *doc = OPCRelationshipSetToDocument(rels);
-        if (!DFSerializeXMLPackage(doc,NAMESPACE_REL,0,pkg->store,relativePath,&error)) {
+        if (!DFSerializeXMLStorage(doc,NAMESPACE_REL,0,pkg->storage,relativePath,&error)) {
             OPCPackageError(pkg,"%s: %s",relativePath,DFErrorMessage(&error));
             DFErrorRelease(error);
         }
@@ -426,9 +426,9 @@ static void saveRelationships(OPCPackage *pkg, OPCRelationshipSet *rels, const c
 static void readRelationships(OPCPackage *pkg, OPCRelationshipSet *rels, const char *partURI)
 {
     char *relFilename = relRelationshipsPathForURI(partURI);
-    if (DFPackageExists(pkg->store,relFilename)) {
+    if (DFStorageExists(pkg->storage,relFilename)) {
         DFError *localError = NULL;
-        DFDocument *relDoc = DFParseXMLPackage(pkg->store,relFilename,&localError);
+        DFDocument *relDoc = DFParseXMLStorage(pkg->storage,relFilename,&localError);
         if (relDoc == NULL) {
             OPCPackageError(pkg,"%s: %s",relFilename,DFErrorMessage(&localError));
             DFErrorRelease(localError);
@@ -494,7 +494,7 @@ void OPCPackageReadRelationships(OPCPackage *pkg, OPCRelationshipSet *rels, cons
 static void findParts(OPCPackage *pkg)
 {
     DFError *error = NULL;
-    const char **contents = DFPackageList(pkg->store,&error);
+    const char **contents = DFStorageList(pkg->storage,&error);
     if (contents == NULL) {
         OPCPackageError(pkg,"findParts: %s",DFErrorMessage(&error));
         DFErrorRelease(error);
@@ -504,7 +504,7 @@ static void findParts(OPCPackage *pkg)
     for (int i = 0; contents[i]; i++) {
         const char *relPath = contents[i];
         char *absPath = DFFormatString("/%s",relPath);
-        if (!DFPackageExists(pkg->store,relPath)) {
+        if (!DFStorageExists(pkg->storage,relPath)) {
             OPCPackageError(pkg,"%s: No such file or directory",relPath);
         }
         else if (!DFStringEqualsCI(absPath,"/[Content_Types].xml") && (strstr(absPath,"/_rels/") == NULL)) {
@@ -516,17 +516,17 @@ static void findParts(OPCPackage *pkg)
     free(contents);
 }
 
-OPCPackage *OPCPackageOpenNew(DFPackage *store, DFError **error)
+OPCPackage *OPCPackageOpenNew(DFStorage *storage, DFError **error)
 {
-    return OPCPackageNew(store);
+    return OPCPackageNew(storage);
 }
 
-OPCPackage *OPCPackageOpenFrom(DFPackage *store, DFError **error)
+OPCPackage *OPCPackageOpenFrom(DFStorage *storage, DFError **error)
 {
     int ok = 0;
-    OPCPackage *pkg = OPCPackageNew(store);
+    OPCPackage *pkg = OPCPackageNew(storage);
 
-    if (!OPCContentTypesLoadFromFile(pkg->contentTypes,pkg->store,"[Content_Types].xml",error))
+    if (!OPCContentTypesLoadFromFile(pkg->contentTypes,pkg->storage,"[Content_Types].xml",error))
         goto end;
 
     findParts(pkg);
@@ -558,7 +558,7 @@ int OPCPackageSaveToDir(OPCPackage *pkg)
 {
     // Save content types
     DFError *dferror = NULL;
-    int ok = OPCContentTypesSaveToFile(pkg->contentTypes,pkg->store,"[Content_Types].xml",&dferror);
+    int ok = OPCContentTypesSaveToFile(pkg->contentTypes,pkg->storage,"[Content_Types].xml",&dferror);
     if (!ok) {
         OPCPackageError(pkg,"%s",DFErrorMessage(&dferror));
         DFErrorRelease(dferror);
@@ -580,7 +580,7 @@ int OPCPackageSave(OPCPackage *pkg, DFError **error)
 {
     if (!OPCPackageSaveToDir(pkg))
         return 0;
-    return DFPackageSave(pkg->store,error);
+    return DFStorageSave(pkg->storage,error);
 }
 
 OPCPart *OPCPackagePartWithURI(OPCPackage *pkg, const char *URI)
@@ -613,7 +613,7 @@ void OPCPackageRemoveRelatedPart(OPCPackage *pkg, const char *URI, const char *r
 
 DFBuffer *OPCPackageReadPart(OPCPackage *pkg, OPCPart *part, DFError **error)
 {
-    DFBuffer *buffer = DFBufferReadFromPackage(pkg->store,part->URI,error);
+    DFBuffer *buffer = DFBufferReadFromStorage(pkg->storage,part->URI,error);
     if (buffer == NULL) {
         DFErrorFormat(error,"%s: %s",part->URI,DFErrorMessage(error));
         return NULL;
@@ -627,7 +627,7 @@ int OPCPackageWritePart(OPCPackage *pkg, const char *data, size_t len, OPCPart *
     int result = 0;
     DFBuffer *buffer = DFBufferNew();
     DFBufferAppendData(buffer,data,len);
-    if (!DFBufferWriteToPackage(buffer,pkg->store,part->URI,error))
+    if (!DFBufferWriteToStorage(buffer,pkg->storage,part->URI,error))
         DFErrorFormat(error,"%s: %s",part->URI,DFErrorMessage(error));
     else
         result = 1;
@@ -637,8 +637,8 @@ int OPCPackageWritePart(OPCPackage *pkg, const char *data, size_t len, OPCPart *
 
 int OPCPackageDeletePart(OPCPackage *pkg, OPCPart *part, DFError **error)
 {
-    if (DFPackageExists(pkg->store,part->URI) &&
-        !DFPackageDelete(pkg->store,part->URI,error)) {
+    if (DFStorageExists(pkg->storage,part->URI) &&
+        !DFStorageDelete(pkg->storage,part->URI,error)) {
         DFErrorFormat(error,"%s: %s",part->URI,DFErrorMessage(error));
         return 0;
     }

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/filters/ooxml/src/common/OPC.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/common/OPC.h b/DocFormats/filters/ooxml/src/common/OPC.h
index 883e174..a7a8050 100644
--- a/DocFormats/filters/ooxml/src/common/OPC.h
+++ b/DocFormats/filters/ooxml/src/common/OPC.h
@@ -18,7 +18,7 @@
 #include "DFXMLForward.h"
 #include "DFError.h"
 #include "DFBuffer.h"
-#include "DFPackage.h"
+#include "DFStorage.h"
 #include "OOXMLTypedefs.h"
 
 // Essentials of the Open Packaging Conventions
@@ -99,7 +99,7 @@ void OPCContentTypesRemoveOverride(OPCContentTypes *ct, const char *partName);
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
 struct OPCPackage {
-    DFPackage *store;
+    DFStorage *storage;
     int isOpen;
     OPCContentTypes *contentTypes;
     OPCRelationshipSet *relationships;
@@ -107,8 +107,8 @@ struct OPCPackage {
     struct DFHashTable *partsByName;
 };
 
-OPCPackage *OPCPackageOpenNew(DFPackage *store, DFError **error);
-OPCPackage *OPCPackageOpenFrom(DFPackage *store, DFError **error);
+OPCPackage *OPCPackageOpenNew(DFStorage *storage, DFError **error);
+OPCPackage *OPCPackageOpenFrom(DFStorage *storage, DFError **error);
 void OPCPackageFree(OPCPackage *pkg);
 int OPCPackageSaveToDir(OPCPackage *pkg);
 int OPCPackageSave(OPCPackage *pkg, DFError **error);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/filters/ooxml/src/word/Word.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/Word.c b/DocFormats/filters/ooxml/src/word/Word.c
index 7217073..7a33866 100644
--- a/DocFormats/filters/ooxml/src/word/Word.c
+++ b/DocFormats/filters/ooxml/src/word/Word.c
@@ -22,18 +22,18 @@
 #include "DFZipFile.h"
 #include <stdlib.h>
 
-DFDocument *WordGet(DFPackage *concretePackage, DFPackage *abstractPackage, DFError **error)
+DFDocument *WordGet(DFStorage *concreteStorage, DFStorage *abstractStorage, DFError **error)
 {
     int ok = 0;
     WordPackage *wordPackage = NULL;
     DFBuffer *warnings = DFBufferNew();
     DFDocument *htmlDoc = NULL;
 
-    wordPackage = WordPackageOpenFrom(concretePackage,error);
+    wordPackage = WordPackageOpenFrom(concreteStorage,error);
     if (wordPackage == NULL)
         goto end;
 
-    htmlDoc = WordPackageGenerateHTML(wordPackage,abstractPackage,"word",error,warnings);
+    htmlDoc = WordPackageGenerateHTML(wordPackage,abstractStorage,"word",error,warnings);
     if (htmlDoc == NULL)
         goto end;
 
@@ -58,7 +58,7 @@ end:
     }
 }
 
-int WordPut(DFPackage *concretePackage, DFPackage *abstractPackage, DFDocument *htmlDoc, DFError **error)
+int WordPut(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, DFError **error)
 {
     int ok = 0;
     WordPackage *wordPackage = NULL;
@@ -66,11 +66,11 @@ int WordPut(DFPackage *concretePackage, DFPackage *abstractPackage, DFDocument *
 
     const char *idPrefix = "word";
 
-    wordPackage = WordPackageOpenFrom(concretePackage,error);
+    wordPackage = WordPackageOpenFrom(concreteStorage,error);
     if (wordPackage == NULL)
         goto end;
 
-    if (!WordPackageUpdateFromHTML(wordPackage,htmlDoc,abstractPackage,idPrefix,error,warnings))
+    if (!WordPackageUpdateFromHTML(wordPackage,htmlDoc,abstractStorage,idPrefix,error,warnings))
         goto end;
 
     if (warnings->len > 0) {
@@ -89,7 +89,7 @@ end:
     return ok;
 }
 
-int WordCreate(DFPackage *concretePackage, DFPackage *abstractPackage, DFDocument *htmlDoc, DFError **error)
+int WordCreate(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, DFError **error)
 {
     int ok = 0;
     WordPackage *wordPackage = NULL;
@@ -97,7 +97,7 @@ int WordCreate(DFPackage *concretePackage, DFPackage *abstractPackage, DFDocumen
 
     const char *idPrefix = "word";
 
-    wordPackage = WordPackageOpenNew(concretePackage,error);
+    wordPackage = WordPackageOpenNew(concreteStorage,error);
     if (wordPackage == NULL)
         goto end;
 
@@ -107,7 +107,7 @@ int WordCreate(DFPackage *concretePackage, DFPackage *abstractPackage, DFDocumen
     // a new word or odf file from it.
     HTMLBreakBDTRefs(htmlDoc->docNode,idPrefix);
 
-    if (!WordPackageUpdateFromHTML(wordPackage,htmlDoc,abstractPackage,idPrefix,error,warnings))
+    if (!WordPackageUpdateFromHTML(wordPackage,htmlDoc,abstractStorage,idPrefix,error,warnings))
         goto end;
 
     if (warnings->len > 0) {
@@ -126,12 +126,12 @@ end:
     return ok;
 }
 
-int WordCollapseBookmarks(DFPackage *concretePackage, DFError **error)
+int WordCollapseBookmarks(DFStorage *concreteStorage, DFError **error)
 {
     int ok = 0;
     WordPackage *wordPackage = NULL;
 
-    wordPackage = WordPackageOpenFrom(concretePackage,error);
+    wordPackage = WordPackageOpenFrom(concreteStorage,error);
     if (wordPackage == NULL)
         goto end;
 
@@ -146,12 +146,12 @@ end:
     return ok;
 }
 
-int WordExpandBookmarks(DFPackage *concretePackage, DFError **error)
+int WordExpandBookmarks(DFStorage *concreteStorage, DFError **error)
 {
     int ok = 0;
     WordPackage *wordPackage = NULL;
 
-    wordPackage = WordPackageOpenFrom(concretePackage,error);
+    wordPackage = WordPackageOpenFrom(concreteStorage,error);
     if (wordPackage == NULL)
         goto end;
 

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/filters/ooxml/src/word/Word.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/Word.h b/DocFormats/filters/ooxml/src/word/Word.h
index 7554eb2..e727786 100644
--- a/DocFormats/filters/ooxml/src/word/Word.h
+++ b/DocFormats/filters/ooxml/src/word/Word.h
@@ -16,7 +16,7 @@
 #define DocFormats_Word_h
 
 #include "DFError.h"
-#include "DFPackage.h"
+#include "DFStorage.h"
 #include "CSSStyle.h"
 #include "CSSSheet.h"
 
@@ -27,10 +27,10 @@
 
 CSSStyle *WordSetupTableGridStyle(CSSSheet *styleSheet, int *changed);
 
-DFDocument *WordGet(DFPackage *concretePackage, DFPackage *abstractPackage, DFError **error);
-int WordPut(DFPackage *concretePackage, DFPackage *abstractPackage, DFDocument *htmlDoc, DFError **error);
-int WordCreate(DFPackage *concretePackage, DFPackage *abstractPackage, DFDocument *htmlDoc, DFError **error);
-int WordCollapseBookmarks(DFPackage *concretePackage, DFError **error);
-int WordExpandBookmarks(DFPackage *concretePackage, DFError **error);
+DFDocument *WordGet(DFStorage *concreteStorage, DFStorage *abstractStorage, DFError **error);
+int WordPut(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, DFError **error);
+int WordCreate(DFStorage *concreteStorage, DFStorage *abstractStorage, DFDocument *htmlDoc, DFError **error);
+int WordCollapseBookmarks(DFStorage *concreteStorage, DFError **error);
+int WordExpandBookmarks(DFStorage *concreteStorage, DFError **error);
 
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/filters/ooxml/src/word/WordConverter.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordConverter.c b/DocFormats/filters/ooxml/src/word/WordConverter.c
index 7b0d90c..33dacaa 100644
--- a/DocFormats/filters/ooxml/src/word/WordConverter.c
+++ b/DocFormats/filters/ooxml/src/word/WordConverter.c
@@ -555,14 +555,14 @@ static void Word_postProcessHTMLDoc(WordConverter *conv)
 //                                                                                                //
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
-WordConverter *WordConverterNew(DFDocument *html, DFPackage *abstractPackage,
+WordConverter *WordConverterNew(DFDocument *html, DFStorage *abstractStorage,
                                 const char *idPrefix, WordPackage *package,
                                 DFBuffer *warnings)
 {
     WordConverter *converter = (WordConverter *)calloc(1,sizeof(WordConverter));
     converter->html = DFDocumentRetain(html);
-    converter->abstractPackage = DFPackageRetain(abstractPackage);
-    assert(DFPackageFormat(converter->abstractPackage) == DFFileFormatHTML);
+    converter->abstractStorage = DFStorageRetain(abstractStorage);
+    assert(DFStorageFormat(converter->abstractStorage) == DFFileFormatHTML);
     converter->idPrefix = DFStrDup(idPrefix);
     converter->package = WordPackageRetain(package);
     converter->styles = WordSheetNew(converter->package->styles);
@@ -587,7 +587,7 @@ WordConverter *WordConverterNew(DFDocument *html, DFPackage *abstractPackage,
 void WordConverterFree(WordConverter *converter)
 {
     DFDocumentRelease(converter->html);
-    DFPackageRelease(converter->abstractPackage);
+    DFStorageRelease(converter->abstractStorage);
     free(converter->idPrefix);
     WordSheetFree(converter->styles);
     WordNumberingFree(converter->numbering);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/filters/ooxml/src/word/WordConverter.h
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordConverter.h b/DocFormats/filters/ooxml/src/word/WordConverter.h
index ebc3cb7..0900e65 100644
--- a/DocFormats/filters/ooxml/src/word/WordConverter.h
+++ b/DocFormats/filters/ooxml/src/word/WordConverter.h
@@ -24,7 +24,7 @@
 #include "CSSSelector.h"
 #include "CSSSheet.h"
 #include "OOXMLTypedefs.h"
-#include "DFPackage.h"
+#include "DFStorage.h"
 
 #define EMUS_PER_POINT 12700
 
@@ -82,7 +82,7 @@ struct WordPutData {
 
 struct WordConverter {
     DFDocument *html;
-    DFPackage *abstractPackage;
+    DFStorage *abstractStorage;
     char *idPrefix;
     WordPackage *package;
     struct WordSheet *styles;
@@ -98,7 +98,7 @@ struct WordConverter {
     CSSSheet *styleSheet;
 };
 
-WordConverter *WordConverterNew(DFDocument *html, DFPackage *abstractPackage,
+WordConverter *WordConverterNew(DFDocument *html, DFStorage *abstractStorage,
                                 const char *idPrefix, WordPackage *package,
                                 DFBuffer *warnings);
 void WordConverterFree(WordConverter *converter);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/8337d187/DocFormats/filters/ooxml/src/word/WordGC.c
----------------------------------------------------------------------
diff --git a/DocFormats/filters/ooxml/src/word/WordGC.c b/DocFormats/filters/ooxml/src/word/WordGC.c
index 4015648..09afaef 100644
--- a/DocFormats/filters/ooxml/src/word/WordGC.c
+++ b/DocFormats/filters/ooxml/src/word/WordGC.c
@@ -67,7 +67,7 @@ static void collect(WordPackage *package, DFHashTable *referencedIds)
         OPCRelationship *rel = OPCRelationshipSetLookupById(relationships,rId);
         if (rel->needsRemoveCheck && (DFHashTableLookup(referencedIds,rel->rId) == NULL)) {
             if (!rel->external)
-                DFPackageDelete(package->opc->store,rel->target,NULL);
+                DFStorageDelete(package->opc->storage,rel->target,NULL);
             OPCRelationshipSetRemove(relationships,rel);
         }
     }


Mime
View raw message