fix: Saving projects to unicode paths not working correctly

This commit is contained in:
WerWolv
2022-12-28 10:46:02 +01:00
parent 5777a6d401
commit f7b988906e
3 changed files with 55 additions and 8 deletions

View File

@@ -9,14 +9,25 @@ namespace hex {
Tar::Tar(const std::fs::path &path, Mode mode) {
int error = MTAR_ESUCCESS;
if (mode == Tar::Mode::Read)
error = mtar_open(&this->m_ctx, path.string().c_str(), "r");
else if (mode == Tar::Mode::Write)
error = mtar_open(&this->m_ctx, path.string().c_str(), "a");
else if (mode == Tar::Mode::Create)
error = mtar_open(&this->m_ctx, path.string().c_str(), "w");
else
error = MTAR_EFAILURE;
#if defined (OS_WINDOWS)
if (mode == Tar::Mode::Read)
error = mtar_wopen(&this->m_ctx, path.c_str(), L"r");
else if (mode == Tar::Mode::Write)
error = mtar_wopen(&this->m_ctx, path.c_str(), L"a");
else if (mode == Tar::Mode::Create)
error = mtar_wopen(&this->m_ctx, path.c_str(), L"w");
else
error = MTAR_EFAILURE;
#else
if (mode == Tar::Mode::Read)
error = mtar_open(&this->m_ctx, path.c_str(), "r");
else if (mode == Tar::Mode::Write)
error = mtar_open(&this->m_ctx, path.c_str(), "a");
else if (mode == Tar::Mode::Create)
error = mtar_open(&this->m_ctx, path.c_str(), "w");
else
error = MTAR_EFAILURE;
#endif
this->m_valid = (error == MTAR_ESUCCESS);
}