api: Moved file extension handling to plugin and added API

This commit is contained in:
WerWolv
2022-01-13 14:34:19 +01:00
parent c88d428fb5
commit 54785b29dd
13 changed files with 100 additions and 17 deletions

View File

@@ -42,6 +42,18 @@ namespace hex::plugin::builtin {
EventManager::subscribe<EventFileUnloaded>(this, [this]{
this->m_dataValid = false;
});
ContentRegistry::FileHandler::add({ ".mgc" }, [](const auto &path) {
for (auto &destPath : hex::getPath(ImHexPath::Magic)) {
std::error_code error;
if (fs::copy_file(path, destPath / path.filename(), fs::copy_options::overwrite_existing, error)) {
View::showMessagePopup("hex.builtin.view.information.magic_db_added"_lang);
return true;
}
}
return false;
});
}
ViewInformation::~ViewInformation() {