From 1fcb2a1a00e425266baa53b0de3530c115957963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Wed, 15 Jun 2016 14:58:01 +0200 Subject: [PATCH] Handle tmp files properly on Android export --- platform/android/export/export.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index b35e3a8055..863b107616 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -232,7 +232,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { void _fix_manifest(Vector& p_manifest, bool p_give_internet); void _fix_resources(Vector& p_manifest); static Error save_apk_file(void *p_userdata,const String& p_path, const Vector& p_data,int p_file,int p_total); - static bool _should_compress_asset(const String& p_path); + static bool _should_compress_asset(const String& p_path, const Vector& p_data); protected: @@ -1003,7 +1003,7 @@ Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata,const String& NULL, 0, NULL, - _should_compress_asset(p_path) ? Z_DEFLATED : 0, + _should_compress_asset(p_path,p_data) ? Z_DEFLATED : 0, Z_DEFAULT_COMPRESSION); @@ -1014,7 +1014,7 @@ Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata,const String& } -bool EditorExportPlatformAndroid::_should_compress_asset(const String& p_path) { +bool EditorExportPlatformAndroid::_should_compress_asset(const String& p_path, const Vector& p_data) { /* * By not compressing files with little or not benefit in doing so, @@ -1049,12 +1049,7 @@ bool EditorExportPlatformAndroid::_should_compress_asset(const String& p_path) { // -- Compressed resource? - FileAccess *f=FileAccess::open(p_path,FileAccess::READ); - ERR_FAIL_COND_V(!f,true); - - uint8_t header[4]; - f->get_buffer(header,4); - if (header[0]=='R' && header[1]=='S' && header[2]=='C' && header[3]=='C') { + if (p_data.size() >= 4 && p_data[0]=='R' && p_data[1]=='S' && p_data[2]=='C' && p_data[3]=='C') { // Already compressed return false; }