| 155 | } |
| 156 | |
| 157 | bool LoadThemeJsonAsset(const char *path, nlohmann::json &out_json) { |
| 158 | auto zip_rc = zip_entry_open(g_ThemeFile, path); |
| 159 | if(zip_rc != 0) { |
| 160 | emscripten_log(EM_LOG_CONSOLE, "Unable to open theme ZIP JSON asset at '%s'...: %d", path, zip_rc); |
| 161 | return false; |
| 162 | } |
| 163 | |
| 164 | void *json_data; |
| 165 | size_t json_data_size; |
| 166 | zip_rc = zip_entry_read(g_ThemeFile, &json_data, &json_data_size); |
| 167 | if(zip_rc <= 0) { |
| 168 | zip_entry_close(g_ThemeFile); |
| 169 | emscripten_log(EM_LOG_CONSOLE, "Unable to read theme ZIP JSON asset at '%s'...: %d", path, zip_rc); |
| 170 | return false; |
| 171 | } |
| 172 | |
| 173 | std::string json_str(reinterpret_cast<const char*>(json_data), json_data_size); |
| 174 | free(json_data); |
| 175 | zip_entry_close(g_ThemeFile); |
| 176 | |
| 177 | out_json = nlohmann::json::parse(json_str); |
| 178 | return true; |
| 179 | } |
| 180 | |
| 181 | bool SaveThemeAsset(zip_t *theme_zip, const std::string &path, const void *data, const size_t data_size) { |
| 182 | auto zip_rc = zip_entry_open(theme_zip, path.c_str()); |