From bcb0ca3efaf79748ce2b422f89dbaceb4ce2a404 Mon Sep 17 00:00:00 2001 From: Brian Schwind Date: Mon, 20 Jul 2015 22:02:48 -0400 Subject: [PATCH] Include correct headers, fix string length bug - AssimpPCH.h appears to have been removed in #536 - There was a bug where if your model data had a null terminator, AndroidJNIIOSystem would incorrectly calculate the number of bytes it needed to write to the file (since it reads a compressed file from the Android assets, and then writes it to the internalDataPath directory for later importing) --- port/AndroidJNI/AndroidJNIIOSystem.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/port/AndroidJNI/AndroidJNIIOSystem.cpp b/port/AndroidJNI/AndroidJNIIOSystem.cpp index 4e8f19187..4a149e050 100644 --- a/port/AndroidJNI/AndroidJNIIOSystem.cpp +++ b/port/AndroidJNI/AndroidJNIIOSystem.cpp @@ -42,7 +42,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @file Android extension of DefaultIOSystem using the standard C file functions */ -#include +#include +#include #if __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT) #include @@ -50,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include #include #include @@ -114,7 +116,7 @@ bool AndroidJNIIOSystem::AndroidExtractAsset(std::string name) // Open file AAsset* asset = AAssetManager_open(mApkAssetManager, name.c_str(), AASSET_MODE_UNKNOWN); - std::string assetContent; + std::vector assetContent; if (asset != NULL) { // Find size @@ -138,7 +140,7 @@ bool AndroidJNIIOSystem::AndroidExtractAsset(std::string name) } // Write output buffer into a file - assetExtracted.write(assetContent.c_str(), strlen(assetContent.c_str())); + assetExtracted.write(&assetContent[0], assetContent.size()); assetExtracted.close(); __android_log_print(ANDROID_LOG_DEFAULT, "Assimp", "Asset extracted");