Core: Remove some uses of OpenCPPFile.

This commit is contained in:
Henrik Rydgård authored and Unknown W. Brackets committed 2021-05-09 17:00:48 -07:00
1 parent 96c109e6ce
commit 2999e1cb86
4 files changed
+42 -54

No files matched your search

+8 -13
View File
@@ -18,6 +18,7 @@
#include "Common/Data/Format/IniFile.h"
#include "Common/File/VFS/VFS.h"
#include "Common/File/FileUtil.h"
#include "Common/Data/Text/Parsers.h"
#ifdef _WIN32
@@ -597,32 +598,26 @@ bool IniFile::Load(std::istream &in) {
bool IniFile::Save(const char* filename)
{
std::ofstream out;
#if defined(_WIN32) && !defined(__MINGW32__)
out.open(ConvertUTF8ToWString(filename), std::ios::out);
#else
out.open(filename, std::ios::out);
#endif
if (out.fail())
{
FILE *file = File::OpenCFile(filename, "w");
if (!file) {
return false;
}
// UTF-8 byte order mark. To make sure notepad doesn't go nuts.
out << "\xEF\xBB\xBF";
// TODO: Do we still need this? It's annoying.
fprintf(file, "\xEF\xBB\xBF");
for (const Section &section : sections) {
if (!section.name().empty() && (!section.lines.empty() || !section.comment.empty())) {
out << "[" << section.name() << "]" << section.comment << std::endl;
fprintf(file, "[%s]%s\n", section.name().c_str(), section.comment.c_str());
}
for (const std::string &s : section.lines) {
out << s << std::endl;
fprintf(file, "%s\n", s.c_str());
}
}
out.close();
fclose(file);
return true;
}