浏览代码

Removed some dead code and fixed the ../ bug in dumpPath and dumpDirectories

Tim Newell 12 年之前
父节点
当前提交
2da27b9010

+ 26 - 0
engine/compilers/android/src/com/garagegames/torque2d/FileWalker.java

@@ -55,6 +55,19 @@ public class FileWalker
 		dumpDirVec.clear();
 		
 		String dirPath = basePath;
+		
+		//remove any ./ from path since the apk code chokes on it
+		while (dirPath.contains("./"))
+			dirPath = dirPath.replace("./", "");
+		
+		//remove any ../ from path since the apk code chokes on it
+		String search = "/../";
+		while (dirPath.contains(search))
+		{
+			int pos = dirPath.indexOf(search);
+			int posStart = dirPath.lastIndexOf("/", pos-1);
+			dirPath = dirPath.substring(0, posStart+1) + dirPath.substring(pos+4);
+		}
 	    
 		if (dirPath.startsWith("/"))
 	    	dirPath = dirPath.substring(1);
@@ -147,6 +160,19 @@ public class FileWalker
 		
 		String dir = dirPath;
 		
+		//remove any ./ from path since the apk code chokes on it
+		while (dir.contains("./"))
+			dir = dir.replace("./", "");
+		
+		//remove any ../ from path since the apk code chokes on it
+		String search = "/../";
+		while (dir.contains(search))
+		{
+			int pos = dir.indexOf(search);
+			int posStart = dir.lastIndexOf("/", pos-1);
+			dir = dir.substring(0, posStart+1) + dir.substring(pos+4);
+		}
+		
 		if (dir.startsWith("/"))
 	    	dir = dir.substring(1);
 		

+ 0 - 16
engine/source/platformAndroid/T2DActivity.cpp

@@ -490,22 +490,6 @@ int _AndroidGetScreenHeight() {
 	return platState.engine->height;
 }
 
-bool _AndroidGetFileDescriptor(const char* fileName, int32_t *mDescriptor, off_t *mStart, off_t* mLength) {
-
-	AAsset* asset = AAssetManager_open(platState.engine->app->activity->assetManager, fileName, AASSET_MODE_UNKNOWN);
-	if (asset != NULL) {
-		*mDescriptor = AAsset_openFileDescriptor(asset, mStart, mLength);
-		AAsset_close(asset);
-		return true;
-	}
-
-	*mDescriptor = 0;
-	*mStart = 0;
-	*mLength = 0;
-
-	return false;
-}
-
 char* _AndroidLoadFile(const char* fn, U32 *size) {
 
 	char fileName[255];