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:
Vendored
+16
@@ -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});
|
||||
|
||||
Reference in New Issue
Block a user