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

@@ -1,14 +1,14 @@
#include <hex/api/project_file_manager.hpp>
#include "window.hpp"
#if defined(OS_MACOS)
#include <hex/api/project_file_manager.hpp>
#include <hex/api/imhex_api.hpp>
#include <hex/api/event_manager.hpp>
#include <hex/helpers/utils_macos.hpp>
#include <hex/helpers/logger.hpp>
#include <hex/helpers/default_paths.hpp>
#include <cstdio>
#include <unistd.h>
@@ -35,7 +35,7 @@ namespace hex {
log::impl::enableColorPrinting();
// Add plugin library folders to dll search path
for (const auto &path : hex::fs::getDefaultPaths(fs::ImHexPath::Libraries)) {
for (const auto &path : paths::Libraries.read()) {
if (std::fs::exists(path))
setenv("LD_LIBRARY_PATH", hex::format("{};{}", hex::getEnvironmentVariable("LD_LIBRARY_PATH").value_or(""), path.string().c_str()).c_str(), true);
}

View File

@@ -1,11 +1,13 @@
#include "window.hpp"
#include "messaging.hpp"
#if defined(OS_WINDOWS)
#include <hex/helpers/utils.hpp>
#include "messaging.hpp"
#include <hex/helpers/utils.hpp>
#include <hex/helpers/logger.hpp>
#include <hex/helpers/default_paths.hpp>
#include <imgui.h>
#include <imgui_internal.h>
@@ -352,7 +354,7 @@ namespace hex {
}
// Add plugin library folders to dll search path
for (const auto &path : hex::fs::getDefaultPaths(fs::ImHexPath::Libraries)) {
for (const auto &path : paths::Libraries.read()) {
if (std::fs::exists(path))
AddDllDirectory(path.c_str());
}

View File

@@ -13,6 +13,7 @@
#include <hex/helpers/utils.hpp>
#include <hex/helpers/fs.hpp>
#include <hex/helpers/logger.hpp>
#include <hex/helpers/default_paths.hpp>
#include <hex/ui/view.hpp>
#include <hex/ui/popup.hpp>
@@ -331,7 +332,7 @@ namespace hex {
ImGui::TableHeadersRow();
for (const auto &path : fs::getDefaultPaths(fs::ImHexPath::Plugins, true)) {
for (const auto &path : paths::Plugins.all()) {
const auto filePath = path / "builtin.hexplug";
ImGui::TableNextRow();
ImGui::TableNextColumn();
@@ -867,8 +868,11 @@ namespace hex {
// If the key name is only one character long, use the ASCII value instead
// Otherwise the keyboard was set to a non-English layout and the key name
// is not the same as the ASCII value
if (name.length() == 1) {
key = std::toupper(name[0]);
if (!name.empty()) {
const std::uint8_t byte = name[0];
if (name.length() == 1 && byte <= 0x7F) {
key = std::toupper(byte);
}
}
}