1
0
mirror of synced 2025-01-11 05:42:15 +01:00

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

@ -1 +1 @@
Subproject commit 6c26a4933891f997142b64572fe86d51cb36bff7
Subproject commit ef8dd504a9173b0a2f25aa52563649e5777536cf

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;
}