fix: Replace old defaults path system with a new one

#1767
This commit is contained in:
WerWolv
2024-06-22 10:44:55 +02:00
parent beef0fff33
commit b60a262b58
41 changed files with 461 additions and 356 deletions

View File

@@ -2,6 +2,7 @@
#include <imgui.h>
#include <hex/api/task_manager.hpp>
#include <hex/helpers/default_paths.hpp>
#include <hex/ui/imgui_imhex_extensions.h>
#include <content/yara_rule.hpp>
@@ -25,7 +26,7 @@ namespace hex::plugin::yara {
};
void process(Task &task, prv::Provider *provider, Region region) override {
for (const auto &yaraSignaturePath : fs::getDefaultPaths(fs::ImHexPath::YaraAdvancedAnalysis)) {
for (const auto &yaraSignaturePath : paths::YaraAdvancedAnalysis.read()) {
for (const auto &ruleFilePath : std::fs::recursive_directory_iterator(yaraSignaturePath)) {
wolv::io::File file(ruleFilePath.path(), wolv::io::File::Mode::Read);
if (!file.isValid())

View File

@@ -4,6 +4,7 @@
#include <hex/api/project_file_manager.hpp>
#include <hex/helpers/fs.hpp>
#include <hex/helpers/default_paths.hpp>
#include <toasts/toast_notification.hpp>
#include <popups/popup_file_chooser.hpp>
@@ -21,7 +22,7 @@ namespace hex::plugin::yara {
YaraRule::init();
ContentRegistry::FileHandler::add({ ".yar", ".yara" }, [](const auto &path) {
for (const auto &destPath : fs::getDefaultPaths(fs::ImHexPath::Yara)) {
for (const auto &destPath : paths::Yara.write()) {
if (wolv::io::fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) {
ui::ToastInfo::open("hex.yara_rules.view.yara.rule_added"_lang);
return true;
@@ -143,7 +144,7 @@ namespace hex::plugin::yara {
}
if (ImGuiExt::IconButton(ICON_VS_ADD, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
const auto basePaths = fs::getDefaultPaths(fs::ImHexPath::Yara);
const auto basePaths = paths::Yara.read();
std::vector<std::fs::path> paths;
for (const auto &path : basePaths) {
std::error_code error;