| 478 | } |
| 479 | |
| 480 | FileAccessPack::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 |
nothing calls this directly
no test coverage detected