| 988 | } |
| 989 | |
| 990 | void ResourceLoaderBinary::open(Ref<FileAccess> p_f, bool p_no_resources, bool p_keep_uuid_paths) { |
| 991 | error = OK; |
| 992 | |
| 993 | f = p_f; |
| 994 | uint8_t header[4]; |
| 995 | f->get_buffer(header, 4); |
| 996 | if (header[0] == 'R' && header[1] == 'S' && header[2] == 'C' && header[3] == 'C') { |
| 997 | // Compressed. |
| 998 | Ref<FileAccessCompressed> fac; |
| 999 | fac.instantiate(); |
| 1000 | error = fac->open_after_magic(f); |
| 1001 | if (error != OK) { |
| 1002 | f.unref(); |
| 1003 | ERR_FAIL_MSG(vformat("Failed to open binary resource file: '%s'.", local_path)); |
| 1004 | } |
| 1005 | f = fac; |
| 1006 | |
| 1007 | } else if (header[0] != 'R' || header[1] != 'S' || header[2] != 'R' || header[3] != 'C') { |
| 1008 | // Not normal. |
| 1009 | error = ERR_FILE_UNRECOGNIZED; |
| 1010 | f.unref(); |
| 1011 | ERR_FAIL_MSG(vformat("Unrecognized binary resource file: '%s'.", local_path)); |
| 1012 | } |
| 1013 | |
| 1014 | bool big_endian = f->get_32(); |
| 1015 | bool use_real64 = f->get_32(); |
| 1016 | |
| 1017 | f->set_big_endian(big_endian != 0); //read big endian if saved as big endian |
| 1018 | |
| 1019 | uint32_t ver_major = f->get_32(); |
| 1020 | uint32_t ver_minor = f->get_32(); |
| 1021 | ver_format = f->get_32(); |
| 1022 | |
| 1023 | print_bl("big endian: " + itos(big_endian)); |
| 1024 | #ifdef BIG_ENDIAN_ENABLED |
| 1025 | print_bl("endian swap: " + itos(!big_endian)); |
| 1026 | #else |
| 1027 | print_bl("endian swap: " + itos(big_endian)); |
| 1028 | #endif |
| 1029 | print_bl("real64: " + itos(use_real64)); |
| 1030 | print_bl("major: " + itos(ver_major)); |
| 1031 | print_bl("minor: " + itos(ver_minor)); |
| 1032 | print_bl("format: " + itos(ver_format)); |
| 1033 | |
| 1034 | if (ver_format > FORMAT_VERSION || ver_major > REDOT_VERSION_MAJOR) { |
| 1035 | f.unref(); |
| 1036 | 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).", |
| 1037 | local_path, ver_format, ver_major, ver_minor, REDOT_VERSION_BRANCH)); |
| 1038 | } |
| 1039 | |
| 1040 | type = get_unicode_string(); |
| 1041 | |
| 1042 | print_bl("type: " + type); |
| 1043 | |
| 1044 | importmd_ofs = f->get_64(); |
| 1045 | uint32_t flags = f->get_32(); |
| 1046 | if (flags & ResourceFormatSaverBinaryInstance::FORMAT_FLAG_NAMED_SCENE_IDS) { |
| 1047 | using_named_scene_ids = true; |
no test coverage detected