Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

WinRT: added platform-specific APIs to access common, writable folder…

… paths
  • Loading branch information
DavidLudwig committed Jan 23, 2013
1 parent 53d5663 commit 97d2e1f576b55e32ba63fb8a0dc1ac856debd1d7
Showing with 92 additions and 0 deletions.
  1. +8 −0 VisualC/SDL/SDL_VS2012_WinRT.vcxproj
  2. +39 −0 include/SDL_system.h
  3. +45 −0 src/core/windowsrt/SDL_winrtpaths.cpp
@@ -53,6 +53,14 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\src\core\windowsrt\SDL_winrtpaths.cpp">
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
<ClCompile Include="..\..\src\cpuinfo\SDL_cpuinfo.c" />
<ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
@@ -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* */
@@ -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__ */

0 comments on commit 97d2e1f

Please sign in to comment.