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

Method rename_dependencies

compat/resource_compat_binary.cpp:1499–1728  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1497}
1498
1499Error ResourceFormatLoaderCompatBinary::rename_dependencies(const String &p_path, const HashMap<String, String> &p_map) {
1500 Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ);
1501 ERR_FAIL_COND_V_MSG(f.is_null(), ERR_CANT_OPEN, vformat("Cannot open file '%s'.", p_path));
1502
1503 Ref<FileAccess> fw;
1504
1505 String local_path = p_path.get_base_dir();
1506
1507 uint8_t header[4];
1508 f->get_buffer(header, 4);
1509 if (header[0] == 'R' && header[1] == 'S' && header[2] == 'C' && header[3] == 'C') {
1510 // Compressed.
1511 Ref<FileAccessCompressed> fac;
1512 fac.instantiate();
1513 Error err = fac->open_after_magic(f);
1514 ERR_FAIL_COND_V_MSG(err != OK, err, vformat("Cannot open file '%s'.", p_path));
1515 f = fac;
1516
1517 Ref<FileAccessCompressed> facw;
1518 facw.instantiate();
1519 facw->configure("RSCC");
1520 err = facw->open_internal(p_path + ".depren", FileAccess::WRITE);
1521 ERR_FAIL_COND_V_MSG(err, ERR_FILE_CORRUPT, vformat("Cannot create file '%s.depren'.", p_path));
1522
1523 fw = facw;
1524
1525 } else if (header[0] != 'R' || header[1] != 'S' || header[2] != 'R' || header[3] != 'C') {
1526 // Not normal.
1527 ERR_FAIL_V_MSG(ERR_FILE_UNRECOGNIZED, vformat("Unrecognized binary resource file '%s'.", local_path));
1528 } else {
1529 fw = FileAccess::open(p_path + ".depren", FileAccess::WRITE);
1530 ERR_FAIL_COND_V_MSG(fw.is_null(), ERR_CANT_CREATE, vformat("Cannot create file '%s.depren'.", p_path));
1531
1532 uint8_t magic[4] = { 'R', 'S', 'R', 'C' };
1533 fw->store_buffer(magic, 4);
1534 }
1535
1536 bool big_endian = f->get_32();
1537 bool use_real64 = f->get_32();
1538
1539 f->set_big_endian(big_endian != 0); //read big endian if saved as big endian
1540
1541 fw->store_32(big_endian);
1542 fw->store_32(use_real64); //use real64
1543 fw->set_big_endian(big_endian != 0);
1544
1545 uint32_t ver_major = f->get_32();
1546 uint32_t ver_minor = f->get_32();
1547 uint32_t ver_format = f->get_32();
1548
1549 if (ver_format < FORMAT_VERSION_CAN_RENAME_DEPS) {
1550 fw.unref();
1551
1552 {
1553 Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
1554 da->remove(p_path + ".depren");
1555 }
1556

Callers

nothing calls this directly

Calls 15

createFunction · 0.85
save_ustringFunction · 0.85
get_ustringFunction · 0.85
removeMethod · 0.80
localize_pathMethod · 0.80
get_uid_for_pathMethod · 0.80
renameMethod · 0.80
get_bufferMethod · 0.45
open_internalMethod · 0.45
store_bufferMethod · 0.45
openMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected