1
0
mirror of synced 2024-11-28 09:30:51 +01:00

build: Always extract magic file database

This commit is contained in:
WerWolv 2023-12-28 19:24:56 +01:00
parent b64bb3bec9
commit 03dc26d2d4
2 changed files with 25 additions and 16 deletions

View File

@ -4,7 +4,7 @@ include(ImHexPlugin)
find_file(DEFAULT_MAGIC_FILE_PATH magic.mgc HINTS ${MAGIC_INCLUDE_DIRS}/../share/misc)
if (DEFAULT_MAGIC_FILE_PATH)
add_romfs_resource(${DEFAULT_MAGIC_FILE_PATH} auto_extract/magic/magic.mgc)
add_romfs_resource(${DEFAULT_MAGIC_FILE_PATH} always_auto_extract/magic/magic.mgc)
endif ()
add_imhex_plugin(

View File

@ -6,10 +6,18 @@
namespace hex::plugin::builtin {
void extractBundledFiles() {
for (const auto &romfsPath : romfs::list("auto_extract")) {
constexpr static std::array<std::pair<std::string_view, bool>, 2> Paths = {
{
{ "auto_extract", false },
{ "always_auto_extract", true }
}
};
for (const auto [extractFolder, alwaysExtract] : Paths) {
for (const auto &romfsPath : romfs::list(extractFolder)) {
for (const auto &imhexPath : fs::getDataPaths()) {
const auto path = imhexPath / std::fs::relative(romfsPath, "auto_extract");
if (wolv::io::fs::exists(path))
const auto path = imhexPath / std::fs::relative(romfsPath, extractFolder);
if (!alwaysExtract && wolv::io::fs::exists(path))
continue;
wolv::io::File file(path, wolv::io::File::Mode::Create);
@ -25,5 +33,6 @@ namespace hex::plugin::builtin {
}
}
}
}