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

Method open

compat/resource_compat_binary.cpp:1143–1293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1141}
1142
1143void ResourceLoaderCompatBinary::open(Ref<FileAccess> p_f, bool p_no_resources, bool p_keep_uuid_paths) {
1144 error = OK;
1145
1146 f = p_f;
1147 uint8_t header[4];
1148 f->get_buffer(header, 4);
1149 if (header[0] == 'R' && header[1] == 'S' && header[2] == 'C' && header[3] == 'C') {
1150 // Compressed.
1151 Ref<FileAccessCompressed> fac;
1152 fac.instantiate();
1153 error = fac->open_after_magic(f);
1154 if (error != OK) {
1155 f.unref();
1156 ERR_FAIL_MSG(vformat("Failed to open binary resource file: '%s'.", local_path));
1157 }
1158 f = fac;
1159 is_compressed = true;
1160 } else if (header[0] != 'R' || header[1] != 'S' || header[2] != 'R' || header[3] != 'C') {
1161 // Not normal.
1162 error = ERR_FILE_UNRECOGNIZED;
1163 f.unref();
1164 ERR_FAIL_MSG(vformat("Unrecognized binary resource file: '%s'.", local_path));
1165 }
1166
1167 bool big_endian = f->get_32();
1168 bool use_real64 = f->get_32();
1169
1170 f->set_big_endian(big_endian != 0); //read big endian if saved as big endian
1171
1172 ver_major = f->get_32();
1173 ver_minor = f->get_32();
1174 ver_format = f->get_32();
1175
1176 stored_big_endian = big_endian;
1177 stored_use_real64 = use_real64;
1178
1179 check_suspect_version();
1180
1181 print_bl("big endian: " + itos(big_endian));
1182#ifdef BIG_ENDIAN_ENABLED
1183 print_bl("endian swap: " + itos(!big_endian));
1184#else
1185 print_bl("endian swap: " + itos(big_endian));
1186#endif
1187 print_bl("real64: " + itos(use_real64));
1188 print_bl("major: " + itos(ver_major));
1189 print_bl("minor: " + itos(ver_minor));
1190 print_bl("format: " + itos(ver_format));
1191
1192 if (ver_format > FORMAT_VERSION || ver_major > GODOT_VERSION_MAJOR) {
1193 f.unref();
1194 ERR_FAIL_MSG(vformat("File '%s' can't be loaded, as it uses a format version (%d) or engine version (%d.%d) which are not supported by your engine version (%s).",
1195 local_path, ver_format, ver_major, ver_minor, VERSION_BRANCH));
1196 }
1197
1198 type = get_unicode_string();
1199
1200 print_bl("type: " + type);

Callers 6

loadMethod · 0.45
rename_dependenciesMethod · 0.45
get_resource_uidMethod · 0.45
custom_loadMethod · 0.45
get_resource_infoMethod · 0.45

Calls 5

push_backMethod · 0.80
get_bufferMethod · 0.45
get_positionMethod · 0.45
resizeMethod · 0.45
eof_reachedMethod · 0.45

Tested by

no test coverage detected