| 1138 | } |
| 1139 | |
| 1140 | static bool LoadInternalStructuresState(zip_t* zf, s64 index, Error* error) |
| 1141 | { |
| 1142 | zip_stat_t zst; |
| 1143 | if (zip_stat_index(zf, index, 0, &zst) != 0 || zst.size > std::numeric_limits<int>::max()) |
| 1144 | return false; |
| 1145 | |
| 1146 | // Load all the internal data |
| 1147 | auto zff = zip_fopen_index_managed(zf, index, 0); |
| 1148 | if (!zff) |
| 1149 | return false; |
| 1150 | |
| 1151 | std::vector<u8> buffer(zst.size); |
| 1152 | if (zip_fread(zff.get(), buffer.data(), buffer.size()) != static_cast<zip_int64_t>(buffer.size())) |
| 1153 | return false; |
| 1154 | |
| 1155 | memLoadingState state(buffer); |
| 1156 | if (!state.FreezeBios()) |
| 1157 | return false; |
| 1158 | |
| 1159 | if (!state.FreezeInternals(error)) |
| 1160 | return false; |
| 1161 | |
| 1162 | return true; |
| 1163 | } |
| 1164 | |
| 1165 | bool SaveState_UnzipFromDisk(const std::string& filename, Error* error) |
| 1166 | { |
no test coverage detected