[Export] Read and ZIP project files in 16K chunks instead of reading the whole file at once.

(cherry picked from commit c8f3dd776b)
This commit is contained in:
bruvzg 2021-11-06 18:58:03 +02:00 committed by Rémi Verschelde
parent 5145c1d783
commit a4b736606f
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 15 additions and 2 deletions

View File

@ -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 0x0314, // "version made by", 0x03 - Unix, 0x14 - ZIP specification version 2.0, required to store Unix file permissions
0); 0);
Vector<uint8_t> array = FileAccess::get_file_as_array(dir.plus_file(f)); FileAccessRef fa = FileAccess::open(dir.plus_file(f), FileAccess::READ);
zipWriteInFileInZip(p_zip, array.ptr(), array.size()); 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); zipCloseFileInZip(p_zip);
} }
} }