Merge pull request #90404 from aaronp64/zipreader_empty_error

Fix `ZIPReader.get_files()` error on empty zip files
This commit is contained in:
Rémi Verschelde 2024-04-08 23:04:35 +02:00
commit 3d382c16ab
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -58,7 +58,14 @@ Error ZIPReader::close() {
PackedStringArray ZIPReader::get_files() {
ERR_FAIL_COND_V_MSG(fa.is_null(), PackedStringArray(), "ZIPReader must be opened before use.");
int err = unzGoToFirstFile(uzf);
unz_global_info gi;
int err = unzGetGlobalInfo(uzf, &gi);
ERR_FAIL_COND_V(err != UNZ_OK, PackedStringArray());
if (gi.number_entry == 0) {
return PackedStringArray();
}
err = unzGoToFirstFile(uzf);
ERR_FAIL_COND_V(err != UNZ_OK, PackedStringArray());
List<String> s;