summaryrefslogtreecommitdiffstats
path: root/platform/osx/export/export_plugin.cpp
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2021-11-06 18:58:03 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2021-11-06 18:58:03 +0200
commitc8f3dd776b54cec54ceba000436035e40218bc3e (patch)
tree7190b576e9a9f6092213c066a51c83052a4f2716 /platform/osx/export/export_plugin.cpp
parent4651b2ae5ca0ed01fb7ff863fbb2e503bf277c84 (diff)
downloadredot-engine-c8f3dd776b54cec54ceba000436035e40218bc3e.tar.gz
[Export] Read and ZIP project files in 16K chunks instead of reading the whole file at once.
Diffstat (limited to 'platform/osx/export/export_plugin.cpp')
-rw-r--r--platform/osx/export/export_plugin.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/platform/osx/export/export_plugin.cpp b/platform/osx/export/export_plugin.cpp
index 1e80dcd97b..a88f7bb332 100644
--- a/platform/osx/export/export_plugin.cpp
+++ b/platform/osx/export/export_plugin.cpp
@@ -1048,8 +1048,21 @@ void EditorExportPlatformOSX::_zip_folder_recursive(zipFile &p_zip, const String
0x0314, // "version made by", 0x03 - Unix, 0x14 - ZIP specification version 2.0, required to store Unix file permissions
0);
- Vector<uint8_t> array = FileAccess::get_file_as_array(dir.plus_file(f));
- zipWriteInFileInZip(p_zip, array.ptr(), array.size());
+ FileAccessRef fa = FileAccess::open(dir.plus_file(f), FileAccess::READ);
+ if (!fa) {
+ ERR_FAIL_MSG("Can't open file to read from path '" + String(dir.plus_file(f)) + "'.");
+ }
+ const int bufsize = 16384;
+ uint8_t buf[bufsize];
+
+ while (true) {
+ uint64_t got = fa->get_buffer(buf, bufsize);
+ if (got == 0) {
+ break;
+ }
+ zipWriteInFileInZip(p_zip, buf, got);
+ }
+
zipCloseFileInZip(p_zip);
}
}