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

@@ -23,6 +23,8 @@
#include <hex/helpers/fmt.hpp>
#include <hex/helpers/logger.hpp>
#include <hex/helpers/utils.hpp>
#include <hex/helpers/default_paths.hpp>
#include <toasts/toast_notification.hpp>
extern "C" void igSetCurrentContext(ImGuiContext* ctx);
@@ -57,7 +59,7 @@ namespace hex::script::loader {
auto netHostLibrary = loadLibrary("libnethost.so");
#elif defined(OS_MACOS)
void *netHostLibrary = nullptr;
for (const auto &pluginPath : fs::getDefaultPaths(fs::ImHexPath::Plugins)) {
for (const auto &pluginPath : paths::Plugins.read()) {
auto frameworksPath = pluginPath.parent_path().parent_path() / "Frameworks";
netHostLibrary = loadLibrary((frameworksPath / "libnethost.dylib").c_str());
@@ -65,7 +67,7 @@ namespace hex::script::loader {
break;
}
if (netHostLibrary == nullptr) {
for (const auto &librariesPath : fs::getDefaultPaths(fs::ImHexPath::Libraries)) {
for (const auto &librariesPath : paths::Libraries.read()) {
netHostLibrary = loadLibrary((librariesPath / "libnethost.dylib").c_str());
if (netHostLibrary != nullptr)
break;
@@ -165,7 +167,7 @@ namespace hex::script::loader {
return false;
}
for (const auto& path : hex::fs::getDefaultPaths(hex::fs::ImHexPath::Plugins)) {
for (const auto& path : paths::Plugins.read()) {
auto assemblyLoader = path / "AssemblyLoader.dll";
if (!wolv::io::fs::exists(assemblyLoader))
continue;
@@ -219,7 +221,7 @@ namespace hex::script::loader {
bool DotNetLoader::loadAll() {
this->clearScripts();
for (const auto &imhexPath : hex::fs::getDefaultPaths(hex::fs::ImHexPath::Scripts)) {
for (const auto &imhexPath : paths::Scripts.read()) {
auto directoryPath = imhexPath / "custom" / "dotnet";
if (!wolv::io::fs::exists(directoryPath))
wolv::io::fs::createDirectories(directoryPath);