aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/package/packagemanager.h
diff options
context:
space:
mode:
authorPaul Gilbert2010-08-22 02:05:31 +0000
committerEugene Sandulenko2010-10-12 23:13:03 +0000
commit2c6201683854d3f56c93f3f2ca1f826b1b2f450e (patch)
treea93dc4563ac7c35753308f0a83c0e894d893b9ec /engines/sword25/package/packagemanager.h
parent4d11cf941e75eecb5682ca74cf92f631d3555671 (diff)
downloadscummvm-rg350-2c6201683854d3f56c93f3f2ca1f826b1b2f450e.tar.gz
scummvm-rg350-2c6201683854d3f56c93f3f2ca1f826b1b2f450e.tar.bz2
scummvm-rg350-2c6201683854d3f56c93f3f2ca1f826b1b2f450e.zip
SWORD25: Added GetXmlFile helper function
The XML files included with the game don't include an XML header line, which is required by the ScummVM XML parser. This helper function encapsulates the GetFile method to return a buffer that includes the required line at the start. svn-id: r53276
Diffstat (limited to 'engines/sword25/package/packagemanager.h')
-rw-r--r--engines/sword25/package/packagemanager.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/engines/sword25/package/packagemanager.h b/engines/sword25/package/packagemanager.h
index 04f863bef8..c441fff122 100644
--- a/engines/sword25/package/packagemanager.h
+++ b/engines/sword25/package/packagemanager.h
@@ -102,6 +102,28 @@ public:
*/
virtual byte *GetFile(const Common::String &FileName, unsigned int *pFileSize = NULL) = 0;
/**
+ * Downloads an XML file and prefixes it with an XML Version key, since the XML files don't contain it,
+ * and it is required for ScummVM to correctly parse the XML.
+ * @param FileName The filename of the file to load
+ * @param pFileSize Pointer to the variable that will contain the size of the loaded file. The deafult is NULL.
+ * @return Specifies a pointer to the loaded data of the file
+ * @remark The client must not forget to release the data of the file using BE_DELETE_A.
+ */
+ char *GetXmlFile(const Common::String &FileName, unsigned int *pFileSize = NULL) {
+ const char *versionStr = "<?xml version=\"1.0\"?>";
+ unsigned int fileSize;
+ char *data = (char *)GetFile(FileName, &fileSize);
+ char *result = (char *)malloc(fileSize + strlen(versionStr) + 1);
+ strcpy(result, versionStr);
+ Common::copy(data, data + fileSize, result + strlen(versionStr));
+ result[fileSize + strlen(versionStr)] = '\0';
+
+ free(data);
+ if (pFileSize) *pFileSize = fileSize + strlen(versionStr);
+ return result;
+ }
+
+ /**
* Returns the path to the current directory.
* @return Returns a string containing the path to the current directory.
* If the path could not be determined, an empty string is returned.