Explorar o código

Merge pull request #614 from bschwind/android-fix

Include correct headers, fix string length bug
Alexander Gessler %!s(int64=10) %!d(string=hai) anos
pai
achega
49d6767551
Modificáronse 1 ficheiros con 5 adicións e 3 borrados
  1. 5 3
      port/AndroidJNI/AndroidJNIIOSystem.cpp

+ 5 - 3
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 */
 /** @file Android extension of DefaultIOSystem using the standard C file functions */
 
 
 
 
-#include <code/AssimpPCH.h>
+#include <assimp/config.h>
+#include <android/api-level.h>
 #if __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
 #if __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT)
 
 
 #include <stdlib.h>
 #include <stdlib.h>
@@ -50,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <android/asset_manager.h>
 #include <android/asset_manager.h>
 #include <android/asset_manager_jni.h>
 #include <android/asset_manager_jni.h>
 #include <android/native_activity.h>
 #include <android/native_activity.h>
+#include <assimp/ai_assert.h>
 #include <assimp/port/AndroidJNI/AndroidJNIIOSystem.h>
 #include <assimp/port/AndroidJNI/AndroidJNIIOSystem.h>
 #include <code/DefaultIOStream.h>
 #include <code/DefaultIOStream.h>
 #include <fstream>
 #include <fstream>
@@ -114,7 +116,7 @@ bool AndroidJNIIOSystem::AndroidExtractAsset(std::string name)
 	// Open file
 	// Open file
 	AAsset* asset = AAssetManager_open(mApkAssetManager, name.c_str(),
 	AAsset* asset = AAssetManager_open(mApkAssetManager, name.c_str(),
 			AASSET_MODE_UNKNOWN);
 			AASSET_MODE_UNKNOWN);
-	std::string assetContent;
+	std::vector<char> assetContent;
 
 
 	if (asset != NULL) {
 	if (asset != NULL) {
 		// Find size
 		// Find size
@@ -138,7 +140,7 @@ bool AndroidJNIIOSystem::AndroidExtractAsset(std::string name)
 		}
 		}
 
 
 		// Write output buffer into a file
 		// Write output buffer into a file
-		assetExtracted.write(assetContent.c_str(), strlen(assetContent.c_str()));
+		assetExtracted.write(&assetContent[0], assetContent.size());
 		assetExtracted.close();
 		assetExtracted.close();
 
 
 		__android_log_print(ANDROID_LOG_DEFAULT, "Assimp", "Asset extracted");
 		__android_log_print(ANDROID_LOG_DEFAULT, "Assimp", "Asset extracted");