--- a/include/SDL_system.h Sun Mar 31 11:44:50 2013 -0400
+++ b/include/SDL_system.h Mon Apr 01 21:33:06 2013 -0400
@@ -135,7 +135,25 @@
* SDL_WinRT_Path for more information on which path types are
* supported where.
*/
-extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFileSystemPath(SDL_WinRT_Path pathType);
+extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType);
+
+/**
+ * \brief Retrieves a Windows RT defined path on the local file system
+ *
+ * \note Documentation on most app-specific path types on Windows RT
+ * can be found on MSDN, at the URL:
+ * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
+ *
+ * \param pathType The type of path to retrieve.
+ * \ret A UTF-8 string (8-bit, multi-byte) containing the path, or NULL
+ * if the path is not available for any reason. Not all paths are
+ * available on all versions of Windows. This is especially true on
+ * Windows Phone. Check the documentation for the given
+ * SDL_WinRT_Path for more information on which path types are
+ * supported where.
+ */
+extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType);
+
#endif /* __WINRT__ */
--- a/src/core/windowsrt/SDL_winrtpaths.cpp Sun Mar 31 11:44:50 2013 -0400
+++ b/src/core/windowsrt/SDL_winrtpaths.cpp Mon Apr 01 21:33:06 2013 -0400
@@ -14,12 +14,13 @@
}
#include <string>
+#include <unordered_map>
using namespace std;
using namespace Windows::Storage;
extern "C" const wchar_t *
-SDL_WinRTGetFileSystemPath(SDL_WinRT_Path pathType)
+SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType)
{
switch (pathType) {
case SDL_WINRT_PATH_INSTALLED_LOCATION:
@@ -68,4 +69,26 @@
return NULL;
}
+extern "C" const char *
+SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
+{
+ typedef unordered_map<SDL_WinRT_Path, string> UTF8PathMap;
+ static UTF8PathMap utf8Paths;
+
+ UTF8PathMap::iterator searchResult = utf8Paths.find(pathType);
+ if (searchResult != utf8Paths.end()) {
+ return searchResult->second.c_str();
+ }
+
+ const wchar_t * ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
+ if (!ucs2Path) {
+ return NULL;
+ }
+
+ char * utf8Path = WIN_StringToUTF8(ucs2Path);
+ utf8Paths[pathType] = utf8Path;
+ SDL_free(utf8Path);
+ return utf8Paths[pathType].c_str();
+}
+
#endif /* __WINRT__ */