Przeglądaj źródła

Bugfix: Banshee now properly handled Unicode file paths

BearishSun 8 lat temu
rodzic
commit
8fb09fee8b

+ 5 - 4
Source/BansheeUtility/FileSystem/BsPath.cpp

@@ -2,6 +2,7 @@
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "Prerequisites/BsPrerequisitesUtil.h"
 #include "Error/BsException.h"
+#include "String/BsUnicode.h"
 
 namespace bs
 {
@@ -173,14 +174,14 @@ namespace bs
 		switch (type)
 		{
 		case PathType::Windows:
-			return bs::toString(buildWindows());
+			return UTF8::fromWide(buildWindows());
 		case PathType::Unix:
-			return bs::toString(buildUnix());
+			return UTF8::fromWide(buildUnix());
 		default:
 #if BS_PLATFORM == BS_PLATFORM_WIN32
-			return bs::toString(buildWindows());
+			return UTF8::fromWide(buildWindows());
 #elif BS_PLATFORM == BS_PLATFORM_OSX || BS_PLATFORM == BS_PLATFORM_LINUX
-			return bs::toString(buildUnix());
+			return UTF8::fromWide(buildUnix());
 #else
 			static_assert(false, "Unsupported platform for path.");
 #endif

+ 4 - 2
Source/BansheeUtility/FileSystem/BsPath.h

@@ -165,6 +165,7 @@ namespace bs
 		 *
 		 * @param[in] type	If set to default path will be parsed according to the rules of the platform the application is 
 		 *					being compiled to. Otherwise it will be parsed according to provided type.
+		 * @return			String representing the path using the wide string encoding.
 		 */
 		WString toWString(PathType type = PathType::Default) const;
 
@@ -173,13 +174,14 @@ namespace bs
 		 *
 		 * @param[in] type	If set to default path will be parsed according to the rules of the platform the application is 
 		 *					being compiled to. Otherwise it will be parsed according to provided type.
+		 * @return			String representing the path using the UTF8 string encoding.
 		 */
 		String toString(PathType type = PathType::Default) const;
 
 		/**
 		 * Converts the path to either a string or a wstring, doing The Right Thing for the current platform.
-         *
-         * This method is equivalent to toWString() on Windows, and to toString() elsewhere.
+		 *
+		 * This method is equivalent to toWString() on Windows, and to toString() elsewhere.
 		 */
 #if BS_PLATFORM == BS_PLATFORM_WIN32
 		WString toPlatformString() const { return toWString(); }

+ 1 - 1
Source/BansheeUtility/Win32/BsWin32PlatformUtility.cpp

@@ -246,7 +246,7 @@ namespace bs
 
 	void PlatformUtility::open(const Path& path)
 	{
-		ShellExecute(nullptr, "open", path.toString().c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+		ShellExecuteW(nullptr, L"open", path.toWString().c_str(), nullptr, nullptr, SW_SHOWNORMAL);
 	}
 
 	HBITMAP Win32PlatformUtility::createBitmap(const Color* pixels, UINT32 width, UINT32 height, bool premultiplyAlpha)

+ 1 - 1
Source/SBansheeEditor/Wrappers/BsScriptSelection.cpp

@@ -122,7 +122,7 @@ namespace bs
 
 		for (UINT32 i = 0; i < (UINT32)paths.size(); i++)
 		{
-			MonoString* monoString = MonoUtil::stringToMono(paths[i].toString());
+			MonoString* monoString = MonoUtil::wstringToMono(paths[i].toWString());
 			pathArray.set(i, monoString);
 		}