summaryrefslogtreecommitdiffstats
path: root/modules/zip/zip_packer.cpp
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2023-06-27 11:49:51 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2023-12-05 17:12:12 +0800
commit08b1354b36c14a9c72128d33db4dbe6e5864a0e2 (patch)
treec8f8b9bc471927ba11a2d2a9b0b8dd34f7a9038c /modules/zip/zip_packer.cpp
parent654132cb9c6ff1f27be0bf325e348e74b3e49fba (diff)
downloadredot-engine-08b1354b36c14a9c72128d33db4dbe6e5864a0e2.tar.gz
Set language encoding flag when using ZIPPacker
When non-ASCII filenames are used, this indicates that the encoding is UTF-8. Programs like ZIPReader can then parse the filename correctly.
Diffstat (limited to 'modules/zip/zip_packer.cpp')
-rw-r--r--modules/zip/zip_packer.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/modules/zip/zip_packer.cpp b/modules/zip/zip_packer.cpp
index 5f623476fc..e67c65d4d1 100644
--- a/modules/zip/zip_packer.cpp
+++ b/modules/zip/zip_packer.cpp
@@ -72,7 +72,24 @@ Error ZIPPacker::start_file(const String &p_path) {
zipfi.internal_fa = 0;
zipfi.external_fa = 0;
- int err = zipOpenNewFileInZip(zf, p_path.utf8().get_data(), &zipfi, nullptr, 0, nullptr, 0, nullptr, Z_DEFLATED, Z_DEFAULT_COMPRESSION);
+ int err = zipOpenNewFileInZip4(zf,
+ p_path.utf8().get_data(),
+ &zipfi,
+ nullptr,
+ 0,
+ nullptr,
+ 0,
+ nullptr,
+ Z_DEFLATED,
+ Z_DEFAULT_COMPRESSION,
+ 0,
+ -MAX_WBITS,
+ DEF_MEM_LEVEL,
+ Z_DEFAULT_STRATEGY,
+ nullptr,
+ 0,
+ 0x0314, // "version made by", 0x03 - Unix, 0x14 - ZIP specification version 2.0, required to store Unix file permissions.
+ 1 << 11); // Bit 11 is the language encoding flag. When set, filename and comment fields must be encoded using UTF-8.
return err == ZIP_OK ? OK : FAILED;
}