maybe...
This commit is contained in:
@@ -23,7 +23,9 @@ namespace anm2ed::anm2
|
||||
{
|
||||
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();
|
||||
return;
|
||||
@@ -56,7 +58,9 @@ namespace anm2ed::anm2
|
||||
XMLDocument 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();
|
||||
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()
|
||||
{
|
||||
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&);
|
||||
|
||||
FILE* open(const std::filesystem::path&, const char*);
|
||||
|
||||
class WorkingDirectory
|
||||
{
|
||||
public:
|
||||
@@ -22,4 +24,14 @@ namespace anm2ed::util::filesystem
|
||||
WorkingDirectory(const std::filesystem::path&, bool = false);
|
||||
~WorkingDirectory();
|
||||
};
|
||||
|
||||
class File
|
||||
{
|
||||
public:
|
||||
FILE* internal{};
|
||||
|
||||
File(const std::filesystem::path&, const char*);
|
||||
~File();
|
||||
FILE* get();
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user