From 0574387ee1840782c97219851359834ba714af42 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 6 May 2023 10:09:23 +0200 Subject: [PATCH] fix: Properly use absolute paths when compiling magic files --- lib/libimhex/source/helpers/magic.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/libimhex/source/helpers/magic.cpp b/lib/libimhex/source/helpers/magic.cpp index 54d1a81f0..a7b38c6a6 100644 --- a/lib/libimhex/source/helpers/magic.cpp +++ b/lib/libimhex/source/helpers/magic.cpp @@ -29,8 +29,10 @@ namespace hex::magic { std::error_code error; for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Magic)) { for (const auto &entry : std::fs::recursive_directory_iterator(dir, error)) { - if (entry.is_regular_file() && ((sourceFiles && entry.path().extension().empty()) || (!sourceFiles && entry.path().extension() == ".mgc"))) { - magicFiles += wolv::util::toUTF8String(wolv::io::fs::toShortPath(entry.path())) + MAGIC_PATH_SEPARATOR; + auto path = std::fs::absolute(entry.path()); + + if (entry.is_regular_file() && ((sourceFiles && path.extension().empty()) || (!sourceFiles && path.extension() == ".mgc"))) { + magicFiles += wolv::util::toUTF8String(wolv::io::fs::toShortPath(path)) + MAGIC_PATH_SEPARATOR; } } }