mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
impr: Bundle default magic file with application
This commit is contained in:
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user