1
0
mirror of synced 2024-11-14 11:07:43 +01:00

fix: Default magic database not being bundled correctly

This commit is contained in:
WerWolv 2024-01-30 21:19:43 +01:00
parent d5365fbf0c
commit 10f6aa3e4e
4 changed files with 23 additions and 2 deletions

View File

@ -616,7 +616,7 @@ macro(addBundledLibraries)
enableUnityBuild(libpl) enableUnityBuild(libpl)
find_package(mbedTLS 3.4.0 REQUIRED) find_package(mbedTLS 3.4.0 REQUIRED)
find_library(MAGIC 5.39 magic REQUIRED) find_package(Magic 5.39 REQUIRED)
if (NOT IMHEX_DISABLE_STACKTRACE) if (NOT IMHEX_DISABLE_STACKTRACE)
if (WIN32) if (WIN32)

View File

@ -0,0 +1,18 @@
find_path(LIBMAGIC_INCLUDE_DIR magic.h)
find_library(LIBMAGIC_LIBRARY NAMES magic)
if (LIBMAGIC_INCLUDE_DIR AND LIBMAGIC_LIBRARY)
set(LIBMAGIC_FOUND TRUE)
endif (LIBMAGIC_INCLUDE_DIR AND LIBMAGIC_LIBRARY)
find_package_handle_standard_args("libmagic" DEFAULT_MSG
LIBMAGIC_LIBRARY
LIBMAGIC_INCLUDE_DIR
)
mark_as_advanced(
LIBMAGIC_INCLUDE_DIR
LIBMAGIC_LIBRARY
LIBMAGIC_FOUND
)

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)
include(ImHexPlugin) include(ImHexPlugin)
find_file(DEFAULT_MAGIC_FILE_PATH magic.mgc HINTS ${MAGIC_INCLUDE_DIRS}/../share/misc) find_file(DEFAULT_MAGIC_FILE_PATH magic.mgc HINTS ${LIBMAGIC_INCLUDE_DIR}/../share/misc)
if (DEFAULT_MAGIC_FILE_PATH) if (DEFAULT_MAGIC_FILE_PATH)
add_romfs_resource(${DEFAULT_MAGIC_FILE_PATH} always_auto_extract/magic/magic.mgc) add_romfs_resource(${DEFAULT_MAGIC_FILE_PATH} always_auto_extract/magic/magic.mgc)
endif () endif ()

View File

@ -3,6 +3,8 @@
#include <wolv/io/file.hpp> #include <wolv/io/file.hpp>
#include <romfs/romfs.hpp> #include <romfs/romfs.hpp>
#include <hex/helpers/logger.hpp>
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
void extractBundledFiles() { void extractBundledFiles() {
@ -17,6 +19,7 @@ namespace hex::plugin::builtin {
for (const auto &romfsPath : romfs::list(extractFolder)) { for (const auto &romfsPath : romfs::list(extractFolder)) {
for (const auto &imhexPath : fs::getDataPaths()) { for (const auto &imhexPath : fs::getDataPaths()) {
const auto path = imhexPath / std::fs::relative(romfsPath, extractFolder); const auto path = imhexPath / std::fs::relative(romfsPath, extractFolder);
log::info("Extracting {} to {}", romfsPath.string(), path.string());
if (!alwaysExtract && wolv::io::fs::exists(path)) if (!alwaysExtract && wolv::io::fs::exists(path))
continue; continue;