diff options
author | HolonProduction <holonproduction@gmail.com> | 2022-11-13 12:50:40 +0100 |
---|---|---|
committer | HolonProduction <holonproduction@gmail.com> | 2022-11-13 12:50:40 +0100 |
commit | ab2373675109104d812499f9bd0f56ce7f2e93c9 (patch) | |
tree | d68ca310b658705be4c0cf3492a17705c4ac5d58 | |
parent | c17f17eb98188a7134c85bdbdf0123127c462046 (diff) |
Fix problem with ZIPPacker
The Zipfile Reference should be set to `NULL` when the `ZIPPacker` is closed not when a file in it is closed.
When calling `ZIPPacker.close` without this nothing happens because `zf` is `NULL`. (7zip could still extract the file but warned about unexpected end of file.)
-rw-r--r-- | modules/zip/zip_packer.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/modules/zip/zip_packer.cpp b/modules/zip/zip_packer.cpp index e62700f191..5566848087 100644 --- a/modules/zip/zip_packer.cpp +++ b/modules/zip/zip_packer.cpp @@ -46,7 +46,11 @@ Error ZIPPacker::open(String p_path, ZipAppend p_append) { Error ZIPPacker::close() { ERR_FAIL_COND_V_MSG(fa.is_null(), FAILED, "ZIPPacker cannot be closed because it is not open."); - return zipClose(zf, NULL) == ZIP_OK ? OK : FAILED; + Error err = zipClose(zf, NULL) == ZIP_OK ? OK : FAILED; + if (err == OK) { + zf = NULL; + } + return err; } Error ZIPPacker::start_file(String p_path) { @@ -79,11 +83,7 @@ Error ZIPPacker::write_file(Vector<uint8_t> p_data) { Error ZIPPacker::close_file() { ERR_FAIL_COND_V_MSG(fa.is_null(), FAILED, "ZIPPacker must be opened before use."); - Error err = zipCloseFileInZip(zf) == ZIP_OK ? OK : FAILED; - if (err == OK) { - zf = NULL; - } - return err; + return zipCloseFileInZip(zf) == ZIP_OK ? OK : FAILED; } void ZIPPacker::_bind_methods() { |