mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-03 05:57:40 -05:00
impr: Bundle default magic file with application
This commit is contained in:
@@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
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)
|
||||
endif ()
|
||||
|
||||
add_imhex_plugin(
|
||||
NAME
|
||||
builtin
|
||||
@@ -36,6 +41,7 @@ add_imhex_plugin(
|
||||
source/content/file_handlers.cpp
|
||||
source/content/project.cpp
|
||||
source/content/achievements.cpp
|
||||
source/content/file_extraction.cpp
|
||||
|
||||
source/content/providers/file_provider.cpp
|
||||
source/content/providers/gdb_provider.cpp
|
||||
|
||||
26
plugins/builtin/source/content/file_extraction.cpp
Normal file
26
plugins/builtin/source/content/file_extraction.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <hex/helpers/fs.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
#include <romfs/romfs.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
void extractBundledFiles() {
|
||||
for (const auto &romfsPath : romfs::list("auto_extract")) {
|
||||
for (const auto &imhexPath : fs::getDataPaths()) {
|
||||
wolv::io::File file(imhexPath, wolv::io::File::Mode::Create);
|
||||
|
||||
if (!file.isValid())
|
||||
continue;
|
||||
|
||||
auto data = romfs::get(romfsPath).span<u8>();
|
||||
file.writeBuffer(data.data(), data.size());
|
||||
|
||||
if (file.getSize() == data.size())
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,6 +47,8 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void handleBorderlessWindowMode();
|
||||
|
||||
void extractBundledFiles();
|
||||
|
||||
}
|
||||
|
||||
IMHEX_PLUGIN_SUBCOMMANDS() {
|
||||
@@ -107,6 +109,8 @@ IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
|
||||
registerMainMenuEntries();
|
||||
|
||||
handleBorderlessWindowMode();
|
||||
|
||||
extractBundledFiles();
|
||||
}
|
||||
|
||||
// This is the default plugin
|
||||
|
||||
Reference in New Issue
Block a user