mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 21:47:40 -05:00
impr: Handle provider opening more centrally, switch to existing provider if same file is being opened again
(cherry picked from commit 89004574d3)
This commit is contained in:
@@ -245,21 +245,19 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
}
|
||||
|
||||
bool IntelHexProvider::open() {
|
||||
prv::Provider::OpenResult IntelHexProvider::open() {
|
||||
auto file = wolv::io::File(m_sourceFilePath, wolv::io::File::Mode::Read);
|
||||
if (!file.isValid()) {
|
||||
this->setErrorMessage(fmt::format("hex.builtin.provider.file.error.open"_lang, m_sourceFilePath.string(), formatSystemError(errno)));
|
||||
return false;
|
||||
return OpenResult::failure(fmt::format("hex.builtin.provider.file.error.open"_lang, m_sourceFilePath.string(), formatSystemError(errno)));
|
||||
}
|
||||
|
||||
auto data = intel_hex::parseIntelHex(file.readString());
|
||||
if (!data.has_value()) {
|
||||
this->setErrorMessage(data.error());
|
||||
return false;
|
||||
return OpenResult::failure(data.error());
|
||||
}
|
||||
processMemoryRegions(data);
|
||||
|
||||
return true;
|
||||
return {};
|
||||
}
|
||||
|
||||
void IntelHexProvider::close() {
|
||||
|
||||
Reference in New Issue
Block a user