1
0
mirror of synced 2024-11-12 10:10:53 +01:00

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,6 +6,15 @@
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 defined(OS_WINDOWS)
if (mode == File::Mode::Read)
this->m_file = _wfopen(path.c_str(), L"rb");
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))
this->m_file = _wfopen(path.c_str(), L"w+b");
#else
if (mode == File::Mode::Read) if (mode == File::Mode::Read)
this->m_file = fopen64(path.string().c_str(), "rb"); this->m_file = fopen64(path.string().c_str(), "rb");
else if (mode == File::Mode::Write) else if (mode == File::Mode::Write)
@ -13,6 +22,7 @@ namespace hex::fs {
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 = fopen64(path.string().c_str(), "w+b");
#endif
} }
File::File() noexcept { File::File() noexcept {