MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / _load_settings_binary

Method _load_settings_binary

utility/pcfg_loader.cpp:273–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271}
272
273Error ProjectConfigLoader::_load_settings_binary(Ref<FileAccess> f, const String &p_path, uint32_t ver_major, bool fail_on_corrupt) {
274 Error err;
275 uint8_t hdr[4];
276 config_version = 0;
277 int bytes_read = f->get_buffer(hdr, 4);
278 if (hdr[0] != 'E' || hdr[1] != 'C' || hdr[2] != 'F' || hdr[3] != 'G') {
279 ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Corrupted header in binary project.binary (not ECFG).");
280 } else if (bytes_read < 4) {
281 WARN_PRINT("Bytes read less than slen!");
282 }
283
284 uint32_t count = f->get_32();
285
286 for (uint32_t i = 0; i < count; i++) {
287 uint32_t slen = f->get_32();
288 CharString cs;
289 cs.resize_uninitialized(slen + 1);
290 cs[slen] = 0;
291 auto actual_bytes_read = f->get_buffer((uint8_t *)cs.ptr(), slen);
292 if (actual_bytes_read < slen) {
293 WARN_PRINT("Bytes read less than slen!");
294 }
295 String key;
296 key.append_utf8(cs.ptr());
297
298 uint32_t vlen = f->get_32();
299 Vector<uint8_t> d;
300 d.resize(vlen);
301 f->get_buffer(d.ptrw(), vlen);
302 Variant value;
303 err = VariantDecoderCompat::decode_variant_compat(ver_major, value, d.ptr(), d.size(), NULL, true);
304 if (err != OK && fail_on_corrupt) {
305 return err;
306 }
307 ERR_CONTINUE_MSG(err != OK, "Error decoding property: " + key + ".");
308 props[key] = VariantContainer(value, last_builtin_order++, true);
309 }
310 cfb_path = p_path;
311 return OK;
312}
313
314Error ProjectConfigLoader::_load_settings_text(Ref<FileAccess> f, const String &p_path, uint32_t ver_major) {
315 Error err;

Callers

nothing calls this directly

Calls 4

VariantContainerClass · 0.85
get_bufferMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected