Create function to read just the rom header so the rom list loads up way quicker (instantaneous on my shitty work laptop)

This commit is contained in:
2026-06-16 10:58:12 +02:00
parent 44dea81bf2
commit e6e33eef17
9 changed files with 143 additions and 49 deletions
+16
View File
@@ -12,6 +12,22 @@ static inline std::vector<u8> read_file_binary(const std::string &path) {
return {std::istreambuf_iterator{file}, {}};
}
static inline std::vector<u8> read_file_binary(const std::string &path, uint32_t size, uint32_t offset = 0) {
FILE *file = fopen(path.c_str(), "rb");
if (!file)
return {};
std::vector<u8> res;
fseek(file, offset, SEEK_SET);
res.resize(size);
fread(res.data(), 1, size, file);
fclose(file);
return res;
}
static inline void write_file_binary(const std::vector<u8> &data, const std::string &path) {
std::ofstream file(path, std::ios::binary);
std::copy(data.begin(), data.end(), std::ostreambuf_iterator{file});