2023-10-29 19:43:40 +01:00
|
|
|
#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()) {
|
2023-12-12 12:15:32 +01:00
|
|
|
const auto path = imhexPath / std::fs::relative(romfsPath, "auto_extract");
|
|
|
|
if (wolv::io::fs::exists(path))
|
|
|
|
continue;
|
2023-10-29 19:43:40 +01:00
|
|
|
|
2023-12-12 12:15:32 +01:00
|
|
|
wolv::io::File file(path, wolv::io::File::Mode::Create);
|
2023-10-29 19:43:40 +01:00
|
|
|
if (!file.isValid())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
auto data = romfs::get(romfsPath).span<u8>();
|
|
|
|
file.writeBuffer(data.data(), data.size());
|
|
|
|
|
|
|
|
if (file.getSize() == data.size())
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|