From e46807c600b5b1efa110156dd39f8a6e7193dda1 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 26 Sep 2021 21:17:46 +0200 Subject: [PATCH] ux: Open dropped pattern files in pattern editor --- source/window/window.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/source/window/window.cpp b/source/window/window.cpp index 9e837fe5d..4a6540a30 100644 --- a/source/window/window.cpp +++ b/source/window/window.cpp @@ -761,7 +761,26 @@ namespace hex { if (count != 1) return; - EventManager::post(paths[0]); + for (u32 i = 0; i < count; i++) { + auto path = std::filesystem::path(paths[i]); + + if (path.extension() == ".hexpat" || path.extension() == ".pat") { + File file(path.string(), File::Mode::Read); + + if (file.isValid()) + EventManager::post(file.readString()); + } else if (path.extension() == ".yar") { + for (auto &destPath : hex::getPath(ImHexPath::Yara)) { + std::error_code error; + std::filesystem::copy(path, destPath, error); + + if (!error) + break; + } + } else { + EventManager::post(path.string()); + } + } }); glfwSetWindowCloseCallback(this->m_window, [](GLFWwindow *window) {