fix: Issues when opening files with unicode names

This commit is contained in:
WerWolv 2022-06-30 14:57:05 +02:00
parent 1f433fc36d
commit 19f99bab0c
2 changed files with 17 additions and 7 deletions

@ -1 +1 @@
Subproject commit ca65dfcf75031f924f21a44ea5605432df6f7ffd Subproject commit f33fc83cedb1e74bd4f583c90ff77b397e7b5c03

View File

@ -6,13 +6,23 @@
namespace hex::fs { namespace hex::fs {
File::File(const std::fs::path &path, Mode mode) noexcept : m_path(path) { File::File(const std::fs::path &path, Mode mode) noexcept : m_path(path) {
if (mode == File::Mode::Read) #if defined(OS_WINDOWS)
this->m_file = fopen64(path.string().c_str(), "rb"); if (mode == File::Mode::Read)
else if (mode == File::Mode::Write) this->m_file = _wfopen(path.c_str(), L"rb");
this->m_file = fopen64(path.string().c_str(), "r+b"); else if (mode == File::Mode::Write)
this->m_file = _wfopen(path.c_str(), L"r+b");
if (mode == File::Mode::Create || (mode == File::Mode::Write && this->m_file == nullptr)) if (mode == File::Mode::Create || (mode == File::Mode::Write && this->m_file == nullptr))
this->m_file = fopen64(path.string().c_str(), "w+b"); this->m_file = _wfopen(path.c_str(), L"w+b");
#else
if (mode == File::Mode::Read)
this->m_file = fopen64(path.string().c_str(), "rb");
else if (mode == File::Mode::Write)
this->m_file = fopen64(path.string().c_str(), "r+b");
if (mode == File::Mode::Create || (mode == File::Mode::Write && this->m_file == nullptr))
this->m_file = fopen64(path.string().c_str(), "w+b");
#endif
} }
File::File() noexcept { File::File() noexcept {