Skip to content

Commit f34c270

Browse files
committed
Merge pull request godotengine#113150 from mihe/file-access-pack-errors
Add back I/O error-handling to `FileAccessPack` constructor
2 parents b7f06bd + 985a5e9 commit f34c270

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

core/io/file_access_pack.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,19 +474,19 @@ FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFil
474474
if (pf.bundle) {
475475
String simplified_path = p_path.simplify_path();
476476
f = FileAccess::open(simplified_path, FileAccess::READ | FileAccess::SKIP_PACK);
477+
ERR_FAIL_COND_MSG(f.is_null(), vformat(R"(Can't open pack-referenced file "%s" from sparse pack "%s".)", simplified_path, pf.pack));
477478
off = 0; // For the sparse pack offset is always zero.
478479
} else {
479480
f = FileAccess::open(pf.pack, FileAccess::READ);
481+
ERR_FAIL_COND_MSG(f.is_null(), vformat(R"(Can't open pack-referenced file "%s" from pack "%s".)", p_path, pf.pack));
480482
f->seek(pf.offset);
481483
off = pf.offset;
482484
}
483485

484-
ERR_FAIL_COND_MSG(f.is_null(), vformat("Can't open pack-referenced file '%s'.", String(pf.pack)));
485-
486486
if (pf.encrypted) {
487487
Ref<FileAccessEncrypted> fae;
488488
fae.instantiate();
489-
ERR_FAIL_COND_MSG(fae.is_null(), vformat("Can't open encrypted pack-referenced file '%s'.", String(pf.pack)));
489+
ERR_FAIL_COND_MSG(fae.is_null(), vformat(R"(Can't open encrypted pack-referenced file "%s" from pack "%s".)", p_path, pf.pack));
490490

491491
Vector<uint8_t> key;
492492
key.resize(32);
@@ -495,7 +495,7 @@ FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFil
495495
}
496496

497497
Error err = fae->open_and_parse(f, key, FileAccessEncrypted::MODE_READ, false);
498-
ERR_FAIL_COND_MSG(err, vformat("Can't open encrypted pack-referenced file '%s'.", String(pf.pack)));
498+
ERR_FAIL_COND_MSG(err, vformat(R"(Can't open encrypted pack-referenced file "%s" from pack "%s".)", p_path, pf.pack));
499499
f = fae;
500500
off = 0;
501501
}

0 commit comments

Comments
 (0)