Parcourir la source

use default_allocator instead of local HeapAllocator

mikymod il y a 12 ans
Parent
commit
01f766bf9c
2 fichiers modifiés avec 15 ajouts et 13 suppressions
  1. 13 8
      engine/os/android/AndroidMountPoint.cpp
  2. 2 5
      engine/os/android/AndroidMountPoint.h

+ 13 - 8
engine/os/android/AndroidMountPoint.cpp

@@ -27,13 +27,13 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "AndroidMountPoint.h"
 #include "AndroidMountPoint.h"
 #include "AndroidFile.h"
 #include "AndroidFile.h"
 #include "StringUtils.h"
 #include "StringUtils.h"
+#include "Allocator.h"
 
 
 namespace crown
 namespace crown
 {
 {
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-AndroidMountPoint::AndroidMountPoint() :
-	MountPoint(ANDROID_TYPE)
+AndroidMountPoint::AndroidMountPoint() : MountPoint(ANDROID_TYPE)
 {
 {
 }
 }
 
 
@@ -43,18 +43,26 @@ File* AndroidMountPoint::open(const char* relative_path, FileOpenMode /*mode*/)
 	CE_ASSERT(exists(relative_path), "File does not exist: %s", relative_path);
 	CE_ASSERT(exists(relative_path), "File does not exist: %s", relative_path);
 	CE_ASSERT(is_file(relative_path), "File is not a regular file: %s", relative_path);
 	CE_ASSERT(is_file(relative_path), "File is not a regular file: %s", relative_path);
 
 
-	return CE_NEW(m_allocator, AndroidFile)(relative_path);
+	return CE_NEW(default_allocator(), AndroidFile)(relative_path);
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void AndroidMountPoint::close(File* file)
 void AndroidMountPoint::close(File* file)
 {
 {
-	CE_DELETE(m_allocator, file);
+	CE_DELETE(default_allocator(), file);
 }
 }
 
 
+//-----------------------------------------------------------------------------
+void AndroidMountPoint::set_root_path(const char* /*root_path*/)
+{
+	Log::w("Stub: Android root path is always assets folder");
+}
+
+
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 const char* AndroidMountPoint::root_path()
 const char* AndroidMountPoint::root_path()
 {
 {
+	Log::w("Stub: Android root path is always assets folder");
 	return "Assets Folder";
 	return "Assets Folder";
 }
 }
 
 
@@ -64,8 +72,6 @@ bool AndroidMountPoint::exists(const char* relative_path)
 	MountPointEntry info;
 	MountPointEntry info;
 
 
 	return get_info(relative_path, info);
 	return get_info(relative_path, info);
-
-	return true;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -78,7 +84,7 @@ bool AndroidMountPoint::get_info(const char* relative_path, MountPointEntry& inf
 	string::strncpy(info.os_path, "", MAX_PATH_LENGTH);
 	string::strncpy(info.os_path, "", MAX_PATH_LENGTH);
 	string::strncpy(info.relative_path, relative_path, MAX_PATH_LENGTH);
 	string::strncpy(info.relative_path, relative_path, MAX_PATH_LENGTH);
 
 
-	AAssetDir* root = AAssetManager_openDir(get_android_asset_manager(), "");
+	AAssetDir* root = AAssetManager_openDir(get_android_asset_manager(), info.os_path);
 
 
 	char asset_name[512];
 	char asset_name[512];
 
 
@@ -86,7 +92,6 @@ bool AndroidMountPoint::get_info(const char* relative_path, MountPointEntry& inf
 
 
 	while (asset_name != NULL)
 	while (asset_name != NULL)
 	{
 	{
-		Log::i("AssetManager: %s", asset_name);
 		if (string::strcmp(asset_name, relative_path) == 0)
 		if (string::strcmp(asset_name, relative_path) == 0)
 		{
 		{
 			info.type = MountPointEntry::FILE;
 			info.type = MountPointEntry::FILE;

+ 2 - 5
engine/os/android/AndroidMountPoint.h

@@ -27,7 +27,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 #pragma once
 
 
 #include "MountPoint.h"
 #include "MountPoint.h"
-#include "HeapAllocator.h"
 
 
 namespace crown
 namespace crown
 {
 {
@@ -41,6 +40,8 @@ public:
 
 
 	void				close(File* file);
 	void				close(File* file);
 
 
+	void				set_root_path(const char*);
+
 	const char*			root_path();
 	const char*			root_path();
 
 
 	bool				exists(const char* relative_path);
 	bool				exists(const char* relative_path);
@@ -52,10 +53,6 @@ public:
 	bool				is_dir(const char* relative_path);
 	bool				is_dir(const char* relative_path);
 
 
 	const char*			os_path(const char* relative_path);
 	const char*			os_path(const char* relative_path);
-
-private:
-
-	HeapAllocator		m_allocator;
 };
 };
 
 
 } // namespace crown
 } // namespace crown