From a4b736606fe41965da0dd2a99e398c84f0d83743 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Sat, 6 Nov 2021 18:58:03 +0200 Subject: [PATCH] [Export] Read and ZIP project files in 16K chunks instead of reading the whole file at once. (cherry picked from commit c8f3dd776b54cec54ceba000436035e40218bc3e) --- platform/osx/export/export.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 33f0bfa894c..7c3d3f24b81 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -1098,8 +1098,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 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); } }