impr: Bundle default magic file with application

This commit is contained in:
WerWolv
2023-10-29 19:43:40 +01:00
parent 80ca6bf177
commit c444ad9280
8 changed files with 100 additions and 14 deletions

View 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;
}
}
}
}