maybe...
This commit is contained in:
@@ -23,7 +23,9 @@ namespace anm2ed::anm2
|
|||||||
{
|
{
|
||||||
XMLDocument document;
|
XMLDocument document;
|
||||||
|
|
||||||
if (document.LoadFile(path.string().c_str()) != XML_SUCCESS)
|
filesystem::File file{path, "rb"};
|
||||||
|
|
||||||
|
if (!file.get() || document.LoadFile(file.get()) != XML_SUCCESS)
|
||||||
{
|
{
|
||||||
if (errorString) *errorString = document.ErrorStr();
|
if (errorString) *errorString = document.ErrorStr();
|
||||||
return;
|
return;
|
||||||
@@ -56,7 +58,9 @@ namespace anm2ed::anm2
|
|||||||
XMLDocument document;
|
XMLDocument document;
|
||||||
document.InsertFirstChild(to_element(document));
|
document.InsertFirstChild(to_element(document));
|
||||||
|
|
||||||
if (document.SaveFile(path.string().c_str()) != XML_SUCCESS)
|
filesystem::File file{path, "w"};
|
||||||
|
|
||||||
|
if (!file.get() || document.SaveFile(file.get()) != XML_SUCCESS)
|
||||||
{
|
{
|
||||||
if (errorString) *errorString = document.ErrorStr();
|
if (errorString) *errorString = document.ErrorStr();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -20,6 +20,19 @@ 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");
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ namespace anm2ed::util::filesystem
|
|||||||
|
|
||||||
std::filesystem::path path_lower_case_backslash_handle(const std::filesystem::path&);
|
std::filesystem::path path_lower_case_backslash_handle(const std::filesystem::path&);
|
||||||
|
|
||||||
|
FILE* open(const std::filesystem::path&, const char*);
|
||||||
|
|
||||||
class WorkingDirectory
|
class WorkingDirectory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -22,4 +24,14 @@ namespace anm2ed::util::filesystem
|
|||||||
WorkingDirectory(const std::filesystem::path&, bool = false);
|
WorkingDirectory(const std::filesystem::path&, bool = false);
|
||||||
~WorkingDirectory();
|
~WorkingDirectory();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class File
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FILE* internal{};
|
||||||
|
|
||||||
|
File(const std::filesystem::path&, const char*);
|
||||||
|
~File();
|
||||||
|
FILE* get();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user