diff --git a/VisualC/SDL/SDL_VS2012_WinRT.vcxproj b/VisualC/SDL/SDL_VS2012_WinRT.vcxproj index a78608bdb..4fd72398a 100644 --- a/VisualC/SDL/SDL_VS2012_WinRT.vcxproj +++ b/VisualC/SDL/SDL_VS2012_WinRT.vcxproj @@ -53,6 +53,14 @@ true true + + true + true + true + true + true + true + diff --git a/include/SDL_system.h b/include/SDL_system.h index 47e557575..0c5348f4b 100644 --- a/include/SDL_system.h +++ b/include/SDL_system.h @@ -93,6 +93,45 @@ extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(); #endif /* __ANDROID__ */ +/* Platform specific functions for Windows RT */ +#if defined(__WINRT__) && __WINRT__ + +/* Gets the path to the local app data store. + Files and directories that should be limited to the local device can be + created in this path. + + This function may be used safely on Windows Phone 8, as opposed to + SDL_WinRTGetRoamingFolderPath() and SDL_WinRTGetTemporaryFolderPath(), + which do not work on Windows Phone 8 (and will return NULL if called + from this platform). + */ +extern DECLSPEC const char * SDLCALL SDL_WinRTGetLocalFolderPath(); + +/* Gets the path to the roaming app data store. + Files and directories that should roam to different devices can be + created in this path. Be sure to read Microsoft's documentation on + roaming files for more information on how this works, as restrictions + do apply. + + Please note that on Windows Phone 8, this function will return NULL, + as Windows Phone 8 apps do not have an accessible roaming app data + store. + */ +extern DECLSPEC const char * SDLCALL SDL_WinRTGetRoamingFolderPath(); + +/* Gets the path to the temporary app data store. + Files and directories may be written here, however they may be deleted + by Windows at a future date. + + Please note that on Windows Phone 8, this function will return NULL, + as Windows Phone 8 apps do not have an accessible temporary app data + store. +*/ +extern DECLSPEC const char * SDLCALL SDL_WinRTGetTemporaryFolderPath(); + +#endif /* __WINRT__ */ + + /* Ends C function definitions when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ diff --git a/src/core/windowsrt/SDL_winrtpaths.cpp b/src/core/windowsrt/SDL_winrtpaths.cpp new file mode 100644 index 000000000..fc33a86ed --- /dev/null +++ b/src/core/windowsrt/SDL_winrtpaths.cpp @@ -0,0 +1,45 @@ +/* TODO, WinRT: include copyright info in SDL_winrtpaths.cpp + TODO, WinRT: add note to SDL_winrtpaths.cpp mentioning that /ZW must be used when compiling the file +*/ + +#include "SDL_config.h" + +#ifdef __WINRT__ + +extern "C" { +#include "SDL_system.h" +#include "../windows/SDL_windows.h" +} + +using namespace Windows::Storage; + +extern "C" const char * SDL_WinRTGetLocalFolderPath() +{ + static const char * path = nullptr; + if (!path) { + path = WIN_StringToUTF8(ApplicationData::Current->LocalFolder->Path->Data()); + } + return path; +} + +extern "C" const char * SDL_WinRTGetRoamingFolderPath() +{ + // TODO, WinRT: make SDL_WinRTGetRoamingFolderPath return NULL on Windows Phone 8 + static const char * path = nullptr; + if (!path) { + path = WIN_StringToUTF8(ApplicationData::Current->RoamingFolder->Path->Data()); + } + return path; +} + +extern "C" const char * SDL_WinRTGetTemporaryFolderPath() +{ + // TODO, WinRT: make SDL_WinRTGetTemporaryFolderPath return NULL on Windows Phone 8 + static const char * path = nullptr; + if (!path) { + path = WIN_StringToUTF8(ApplicationData::Current->TemporaryFolder->Path->Data()); + } + return path; +} + +#endif /* __WINRT__ */