fix: Crash when saving patches

Fixes #1077
This commit is contained in:
WerWolv 2023-05-19 20:01:42 +02:00
parent 39276e123e
commit 4ad66365d0
1 changed files with 8 additions and 4 deletions

View File

@ -193,12 +193,16 @@ namespace hex::plugin::builtin {
this->m_readable = true;
this->m_writable = true;
wolv::io::File file(this->m_path, wolv::io::File::Mode::Read);
wolv::io::File file(this->m_path, wolv::io::File::Mode::Write);
if (!file.isValid()) {
this->m_writable = false;
this->m_readable = false;
this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, this->m_path.string(), ::strerror(errno)));
return false;
file = wolv::io::File(this->m_path, wolv::io::File::Mode::Read);
if (!file.isValid()) {
this->m_readable = false;
this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, this->m_path.string(), ::strerror(errno)));
return false;
}
}
this->m_fileStats = file.getFileInfo();