impr: Added better file open error messages to the file provider

This commit is contained in:
WerWolv
2024-12-23 14:07:35 +01:00
parent 470523cc86
commit 1c5a50c8d8
2 changed files with 5 additions and 8 deletions

View File

@@ -202,8 +202,10 @@ namespace hex::plugin::builtin {
size_t fileSize = 0x00;
{
wolv::io::File file(m_path, wolv::io::File::Mode::Read);
if (!file.isValid())
if (!file.isValid()) {
this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, m_path.string(), std::system_category().message(file.getOpenError().value_or(0))));
return false;
}
fileSize = file.getSize();
}
@@ -231,11 +233,6 @@ namespace hex::plugin::builtin {
m_readable = true;
m_writable = true;
if (!wolv::io::fs::exists(m_path)) {
this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, m_path.string(), std::system_category().message(ENOENT)));
return false;
}
wolv::io::File file(m_path, wolv::io::File::Mode::Write);
if (!file.isValid()) {
m_writable = false;
@@ -243,7 +240,7 @@ namespace hex::plugin::builtin {
file = wolv::io::File(m_path, wolv::io::File::Mode::Read);
if (!file.isValid()) {
m_readable = false;
this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, m_path.string(), std::system_category().message(errno)));
this->setErrorMessage(hex::format("hex.builtin.provider.file.error.open"_lang, m_path.string(), std::system_category().message(file.getOpenError().value_or(0))));
return false;
}