[Scummvm-cvs-logs] SF.net SVN: scummvm:[53276] scummvm/trunk/engines/sword25/package/ packagemanager.h
sev at users.sourceforge.net
sev at users.sourceforge.net
Wed Oct 13 01:13:03 CEST 2010
Revision: 53276
http://scummvm.svn.sourceforge.net/scummvm/?rev=53276&view=rev
Author: sev
Date: 2010-10-12 23:13:03 +0000 (Tue, 12 Oct 2010)
Log Message:
-----------
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.
Modified Paths:
--------------
scummvm/trunk/engines/sword25/package/packagemanager.h
Modified: scummvm/trunk/engines/sword25/package/packagemanager.h
===================================================================
--- scummvm/trunk/engines/sword25/package/packagemanager.h 2010-10-12 23:12:41 UTC (rev 53275)
+++ scummvm/trunk/engines/sword25/package/packagemanager.h 2010-10-12 23:13:03 UTC (rev 53276)
@@ -102,6 +102,28 @@
*/
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.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list