Просмотр исходного кода

Implement normalize_path for Linux and Android

Daniele Bartolini 12 лет назад
Родитель
Сommit
82a3592084
2 измененных файлов с 43 добавлено и 2 удалено
  1. 24 0
      engine/os/android/AndroidOS.cpp
  2. 19 2
      engine/os/linux/LinuxOS.cpp

+ 24 - 0
engine/os/android/AndroidOS.cpp

@@ -201,6 +201,30 @@ void list_files(const char* path, Vector<DynamicString>& files)
 	closedir(dir);
 }
 
+//-----------------------------------------------------------------------------
+const char* normalize_path(const char* path)
+{
+	static char norm[MAX_PATH_LENGTH];
+	char* cur = norm;
+
+	while ((*path) != '\0')
+	{
+		if ((*path) == '\\')
+		{
+			(*cur) = PATH_SEPARATOR;
+		}
+		else
+		{
+			(*cur) = (*path);
+		}
+
+		path++;
+		cur++;
+	}
+
+	return norm;
+}
+
 //-----------------------------------------------------------------------------
 const char* get_cwd()
 {

+ 19 - 2
engine/os/linux/LinuxOS.cpp

@@ -209,8 +209,25 @@ void list_files(const char* path, Vector<DynamicString>& files)
 //-----------------------------------------------------------------------------
 const char* normalize_path(const char* path)
 {
-	// Stub function
-	return path;
+	static char norm[MAX_PATH_LENGTH];
+	char* cur = norm;
+
+	while ((*path) != '\0')
+	{
+		if ((*path) == '\\')
+		{
+			(*cur) = PATH_SEPARATOR;
+		}
+		else
+		{
+			(*cur) = (*path);
+		}
+
+		path++;
+		cur++;
+	}
+
+	return norm;
 }
 
 //-----------------------------------------------------------------------------