MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / FileAccessPack

Method FileAccessPack

core/io/file_access_pack.cpp:480–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

478}
479
480FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file) {
481 pf = p_file;
482 if (pf.bundle) {
483 String simplified_path = p_path.simplify_path();
484 f = FileAccess::open(simplified_path, FileAccess::READ | FileAccess::SKIP_PACK);
485 off = 0; // For the sparse pack offset is always zero.
486 } else {
487 f = FileAccess::open(pf.pack, FileAccess::READ);
488 f->seek(pf.offset);
489 off = pf.offset;
490 }
491
492 ERR_FAIL_COND_MSG(f.is_null(), vformat("Can't open pack-referenced file '%s'.", String(pf.pack)));
493
494 if (pf.encrypted) {
495 Ref<FileAccessEncrypted> fae;
496 fae.instantiate();
497 ERR_FAIL_COND_MSG(fae.is_null(), vformat("Can't open encrypted pack-referenced file '%s'.", String(pf.pack)));
498
499 Vector<uint8_t> key;
500 key.resize(32);
501 for (int i = 0; i < key.size(); i++) {
502 key.write[i] = script_encryption_key[i];
503 }
504
505 Error err = fae->open_and_parse(f, key, FileAccessEncrypted::MODE_READ, false);
506 ERR_FAIL_COND_MSG(err, vformat("Can't open encrypted pack-referenced file '%s'.", String(pf.pack)));
507 f = fae;
508 off = 0;
509 }
510 pos = 0;
511 eof = false;
512}
513
514//////////////////////////////////////////////////////////////////////////////////
515// DIR ACCESS

Callers

nothing calls this directly

Calls 9

vformatFunction · 0.85
open_and_parseMethod · 0.80
sizeMethod · 0.65
StringClass · 0.50
simplify_pathMethod · 0.45
seekMethod · 0.45
is_nullMethod · 0.45
instantiateMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected