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

Method set_uid

compat/resource_compat_binary.cpp:2768–2882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2766}
2767
2768Error ResourceFormatSaverCompatBinaryInstance::set_uid(const String &p_path, ResourceUID::ID p_uid) {
2769 Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ);
2770 ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_OPEN, vformat("Cannot open file '%s'.", p_path));
2771
2772 Ref<FileAccess> fw;
2773
2774 local_path = p_path.get_base_dir();
2775
2776 uint8_t header[4];
2777 f->get_buffer(header, 4);
2778 if (header[0] == 'R' && header[1] == 'S' && header[2] == 'C' && header[3] == 'C') {
2779 // Compressed.
2780 Ref<FileAccessCompressed> fac;
2781 fac.instantiate();
2782 Error err = fac->open_after_magic(f);
2783 ERR_FAIL_COND_V_MSG(err != OK, err, vformat("Cannot open file '%s'.", p_path));
2784 f = fac;
2785
2786 Ref<FileAccessCompressed> facw;
2787 facw.instantiate();
2788 facw->configure("RSCC");
2789 err = facw->open_internal(p_path + ".uidren", FileAccess::WRITE);
2790 ERR_FAIL_COND_V_MSG(err, ERR_FILE_CORRUPT, vformat("Cannot create file '%s.uidren'.", p_path));
2791
2792 fw = facw;
2793
2794 } else if (header[0] != 'R' || header[1] != 'S' || header[2] != 'R' || header[3] != 'C') {
2795 // Not a binary resource.
2796 return ERR_FILE_UNRECOGNIZED;
2797 } else {
2798 fw = FileAccess::open(p_path + ".uidren", FileAccess::WRITE);
2799 ERR_FAIL_COND_V_MSG(fw.is_null(), ERR_CANT_CREATE, vformat("Cannot create file '%s.uidren'.", p_path));
2800
2801 uint8_t magich[4] = { 'R', 'S', 'R', 'C' };
2802 fw->store_buffer(magich, 4);
2803 }
2804
2805 big_endian = f->get_32();
2806 bool use_real64 = f->get_32();
2807 f->set_big_endian(big_endian != 0); //read big endian if saved as big endian
2808#ifdef BIG_ENDIAN_ENABLED
2809 fw->store_32(!big_endian);
2810#else
2811 fw->store_32(big_endian);
2812#endif
2813 fw->set_big_endian(big_endian != 0);
2814 fw->store_32(use_real64); //use real64
2815
2816 uint32_t major = f->get_32();
2817 uint32_t minor = f->get_32();
2818 uint32_t format = f->get_32();
2819
2820 if (format <= FORMAT_VERSION_NO_NODEPATH_PROPERTY) {
2821 fw.unref();
2822
2823 {
2824 Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
2825 da->remove(p_path + ".uidren");

Callers

nothing calls this directly

Calls 13

createFunction · 0.85
save_ustringFunction · 0.85
get_ustringFunction · 0.85
removeMethod · 0.80
renameMethod · 0.80
localize_pathMethod · 0.80
get_bufferMethod · 0.45
open_internalMethod · 0.45
store_bufferMethod · 0.45
get_8Method · 0.45
eof_reachedMethod · 0.45
store_8Method · 0.45

Tested by

no test coverage detected