1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-25 05:58:30 +02:00

Add FILESYSTEM_saveTiXml2Document()

This will eventually replace FILESYSTEM_saveTiXmlDocument(). Read it as
"save TinyXML2 Document", not "save TinyXML to Document".
This commit is contained in:
Misa 2020-06-03 09:54:05 -07:00 committed by Ethan Lee
parent b67ac8a43b
commit 45ad048756
2 changed files with 17 additions and 0 deletions

View File

@ -282,6 +282,21 @@ bool FILESYSTEM_loadTiXmlDocument(const char *name, TiXmlDocument *doc)
return true;
}
bool FILESYSTEM_saveTiXml2Document(const char *name, tinyxml2::XMLDocument& doc)
{
/* XMLDocument.SaveFile doesn't account for Unicode paths, PHYSFS does */
tinyxml2::XMLPrinter printer;
doc.Print(&printer);
PHYSFS_File* handle = PHYSFS_openWrite(name);
if (handle == NULL)
{
return false;
}
PHYSFS_writeBytes(handle, printer.CStr(), printer.CStrSize() - 1); // subtract one because CStrSize includes terminating null
PHYSFS_close(handle);
return true;
}
std::vector<std::string> FILESYSTEM_getLevelDirFileNames()
{
std::vector<std::string> list;

View File

@ -5,6 +5,7 @@
#include <vector>
#include "tinyxml.h"
#include "tinyxml2.h"
int FILESYSTEM_init(char *argvZero, char* baseDir, char* assetsPath);
void FILESYSTEM_deinit();
@ -21,6 +22,7 @@ void FILESYSTEM_loadFileToMemory(const char *name, unsigned char **mem,
void FILESYSTEM_freeMemory(unsigned char **mem);
bool FILESYSTEM_saveTiXmlDocument(const char *name, TiXmlDocument *doc);
bool FILESYSTEM_loadTiXmlDocument(const char *name, TiXmlDocument *doc);
bool FILESYSTEM_saveTiXml2Document(const char *name, tinyxml2::XMLDocument& doc);
std::vector<std::string> FILESYSTEM_getLevelDirFileNames();