mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-07-23 02:25:52 -04:00
a8559bfbbc
* Update all CMakeLists of extensions to use clang-format * Run clang-format on all Extensions * Update GDCore CMakeLists.txt to add clang-format * Run clang-format on GDCore files * Update GDJS and GDCpp CMakeLists.txt to add clang-format * Run clang-format on GDCpp and GDJS files
40 lines
908 B
C++
40 lines
908 B
C++
#include "GDCore/Tools/XmlLoader.h"
|
|
|
|
#include <cstdio>
|
|
|
|
namespace gd {
|
|
|
|
namespace {
|
|
FILE* GetFileHandle(const gd::String& filename, const gd::String& mode) {
|
|
#if defined(WINDOWS)
|
|
return _wfopen(filename.ToWide().c_str(), mode.ToWide().c_str());
|
|
#else
|
|
return fopen(filename.ToLocale().c_str(), mode.ToLocale().c_str());
|
|
#endif
|
|
}
|
|
} // namespace
|
|
|
|
bool GD_CORE_API LoadXmlFromFile(TiXmlDocument& doc,
|
|
const gd::String& filepath) {
|
|
FILE* xmlFile = GetFileHandle(filepath, "rb");
|
|
if (!xmlFile) return false;
|
|
|
|
bool res = doc.LoadFile(xmlFile);
|
|
fclose(xmlFile);
|
|
|
|
return res;
|
|
}
|
|
|
|
bool GD_CORE_API SaveXmlToFile(const TiXmlDocument& doc,
|
|
const gd::String& filepath) {
|
|
FILE* xmlFile = GetFileHandle(filepath, "wb");
|
|
if (!xmlFile) return false;
|
|
|
|
bool res = doc.SaveFile(xmlFile);
|
|
fclose(xmlFile);
|
|
|
|
return res;
|
|
}
|
|
|
|
} // namespace gd
|