You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
Add back I/O error-handling to FileAccessPack constructor
This commit is contained in:
@@ -474,19 +474,19 @@ FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFil
|
|||||||
if (pf.bundle) {
|
if (pf.bundle) {
|
||||||
String simplified_path = p_path.simplify_path();
|
String simplified_path = p_path.simplify_path();
|
||||||
f = FileAccess::open(simplified_path, FileAccess::READ | FileAccess::SKIP_PACK);
|
f = FileAccess::open(simplified_path, FileAccess::READ | FileAccess::SKIP_PACK);
|
||||||
|
ERR_FAIL_COND_MSG(f.is_null(), vformat(R"(Can't open pack-referenced file "%s" from sparse pack "%s".)", simplified_path, pf.pack));
|
||||||
off = 0; // For the sparse pack offset is always zero.
|
off = 0; // For the sparse pack offset is always zero.
|
||||||
} else {
|
} else {
|
||||||
f = FileAccess::open(pf.pack, FileAccess::READ);
|
f = FileAccess::open(pf.pack, FileAccess::READ);
|
||||||
|
ERR_FAIL_COND_MSG(f.is_null(), vformat(R"(Can't open pack-referenced file "%s" from pack "%s".)", p_path, pf.pack));
|
||||||
f->seek(pf.offset);
|
f->seek(pf.offset);
|
||||||
off = pf.offset;
|
off = pf.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
ERR_FAIL_COND_MSG(f.is_null(), vformat("Can't open pack-referenced file '%s'.", String(pf.pack)));
|
|
||||||
|
|
||||||
if (pf.encrypted) {
|
if (pf.encrypted) {
|
||||||
Ref<FileAccessEncrypted> fae;
|
Ref<FileAccessEncrypted> fae;
|
||||||
fae.instantiate();
|
fae.instantiate();
|
||||||
ERR_FAIL_COND_MSG(fae.is_null(), vformat("Can't open encrypted pack-referenced file '%s'.", String(pf.pack)));
|
ERR_FAIL_COND_MSG(fae.is_null(), vformat(R"(Can't open encrypted pack-referenced file "%s" from pack "%s".)", p_path, pf.pack));
|
||||||
|
|
||||||
Vector<uint8_t> key;
|
Vector<uint8_t> key;
|
||||||
key.resize(32);
|
key.resize(32);
|
||||||
@@ -495,7 +495,7 @@ FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFil
|
|||||||
}
|
}
|
||||||
|
|
||||||
Error err = fae->open_and_parse(f, key, FileAccessEncrypted::MODE_READ, false);
|
Error err = fae->open_and_parse(f, key, FileAccessEncrypted::MODE_READ, false);
|
||||||
ERR_FAIL_COND_MSG(err, vformat("Can't open encrypted pack-referenced file '%s'.", String(pf.pack)));
|
ERR_FAIL_COND_MSG(err, vformat(R"(Can't open encrypted pack-referenced file "%s" from pack "%s".)", p_path, pf.pack));
|
||||||
f = fae;
|
f = fae;
|
||||||
off = 0;
|
off = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user