checking...
This commit is contained in:
@@ -23,9 +23,13 @@ namespace anm2ed::anm2
|
|||||||
{
|
{
|
||||||
XMLDocument document;
|
XMLDocument document;
|
||||||
|
|
||||||
filesystem::File file{path, "rb"};
|
#ifdef _WIN32
|
||||||
|
auto file = _wfopen(path.string().c_str(), L"rb");
|
||||||
|
#else
|
||||||
|
auto file = fopen(path.c_str(), "rb");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!file.get() || document.LoadFile(file.get()) != XML_SUCCESS)
|
if (!file || document.LoadFile(file) != XML_SUCCESS)
|
||||||
{
|
{
|
||||||
if (errorString) *errorString = document.ErrorStr();
|
if (errorString) *errorString = document.ErrorStr();
|
||||||
return;
|
return;
|
||||||
@@ -58,9 +62,13 @@ namespace anm2ed::anm2
|
|||||||
XMLDocument document;
|
XMLDocument document;
|
||||||
document.InsertFirstChild(to_element(document));
|
document.InsertFirstChild(to_element(document));
|
||||||
|
|
||||||
filesystem::File file{path, "w"};
|
#ifdef _WIN32
|
||||||
|
auto file = _wfopen(path.string().c_str(), L"w");
|
||||||
|
#else
|
||||||
|
auto file = fopen(path.c_str(), "w");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!file.get() || document.SaveFile(file.get()) != XML_SUCCESS)
|
if (!file || document.SaveFile(file) != XML_SUCCESS)
|
||||||
{
|
{
|
||||||
if (errorString) *errorString = document.ErrorStr();
|
if (errorString) *errorString = document.ErrorStr();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -20,19 +20,6 @@ namespace anm2ed::util::filesystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File::File(const std::filesystem::path& path, const char* mode)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
_wfopen_s(&this->internal, path.c_str(), mode);
|
|
||||||
#else
|
|
||||||
this->internal = fopen(path.c_str(), mode);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
File::~File() { fclose(this->internal); }
|
|
||||||
|
|
||||||
FILE* File::get() { return internal; }
|
|
||||||
|
|
||||||
std::filesystem::path path_preferences_get()
|
std::filesystem::path path_preferences_get()
|
||||||
{
|
{
|
||||||
auto path = SDL_GetPrefPath(nullptr, "anm2ed");
|
auto path = SDL_GetPrefPath(nullptr, "anm2ed");
|
||||||
|
|||||||
@@ -25,13 +25,4 @@ namespace anm2ed::util::filesystem
|
|||||||
~WorkingDirectory();
|
~WorkingDirectory();
|
||||||
};
|
};
|
||||||
|
|
||||||
class File
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FILE* internal{};
|
|
||||||
|
|
||||||
File(const std::filesystem::path&, const char*);
|
|
||||||
~File();
|
|
||||||
FILE* get();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user