Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
WinRT: consolidated all WinRT path-retrieval functions into one function
  • Loading branch information
DavidLudwig committed Feb 10, 2013
1 parent 450a305 commit 893f11d5431a8916ad6a71bf80801fd15b45f661
Showing with 76 additions and 74 deletions.
  1. +34 −32 include/SDL_system.h
  2. +40 −40 src/core/windowsrt/SDL_winrtpaths.cpp
  3. +2 −2 src/render/direct3d11/SDL_render_d3d11.cpp
@@ -96,44 +96,46 @@ extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath();
/* Platform specific functions for Windows RT */
#if defined(__WINRT__) && __WINRT__

/* Gets the path to the installed app's root directory.
/**
* \brief Windows RT / Windows Phone path types
*/
typedef enum
{
/** \brief The installed app's root directory.
Files here are likely to be read-only. */
SDL_WINRT_PATH_INSTALLED_LOCATION,

This function may be used safely on Windows Phone 8.
*/
extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetInstalledLocationPath();
/** \brief The app's local data store. Files may be written here */
SDL_WINRT_PATH_LOCAL_FOLDER,

/* 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.
/** \brief The app's roaming data store. Unsupported on Windows Phone.
Files written here may be copied to other machines via a network
connection.
*/
SDL_WINRT_PATH_ROAMING_FOLDER,

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 wchar_t * SDLCALL SDL_WinRTGetLocalFolderPath();
/** \brief The app's temporary data store. Unsupported on Windows Phone.
Files written here may be deleted at any time. */
SDL_WINRT_PATH_TEMP_FOLDER
} SDL_WinRT_Path;

/* 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.
/**
* \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 UCS-2 string (16-bit, wide-char) 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 wchar_t * 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 wchar_t * SDLCALL SDL_WinRTGetTemporaryFolderPath();
extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFileSystemPath(SDL_WinRT_Path pathType);

#endif /* __WINRT__ */

@@ -19,53 +19,53 @@ using namespace std;
using namespace Windows::Storage;

extern "C" const wchar_t *
SDL_WinRTGetInstalledLocationPath()
SDL_WinRTGetFileSystemPath(SDL_WinRT_Path pathType)
{
static wstring path;
if (path.empty()) {
path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
}
return path.c_str();
}
switch (pathType) {
case SDL_WINRT_PATH_INSTALLED_LOCATION:
{
static wstring path;
if (path.empty()) {
path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
}
return path.c_str();
}

extern "C" const wchar_t *
SDL_WinRTGetLocalFolderPath()
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->LocalFolder->Path->Data();
}
return path.c_str();
}
case SDL_WINRT_PATH_LOCAL_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->LocalFolder->Path->Data();
}
return path.c_str();
}

extern "C" const wchar_t *
SDL_WinRTGetRoamingFolderPath()
{
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
SDL_Unsupported();
return NULL;
#else
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->RoamingFolder->Path->Data();
}
return path.c_str();
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
case SDL_WINRT_PATH_ROAMING_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->RoamingFolder->Path->Data();
}
return path.c_str();
}

case SDL_WINRT_PATH_TEMP_FOLDER:
{
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->TemporaryFolder->Path->Data();
}
return path.c_str();
}
#endif
}

extern "C" const wchar_t *
SDL_WinRTGetTemporaryFolderPath()
{
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
default:
break;
}

SDL_Unsupported();
return NULL;
#else
static wstring path;
if (path.empty()) {
path = ApplicationData::Current->TemporaryFolder->Path->Data();
}
return path.c_str();
#endif
}

#endif /* __WINRT__ */
@@ -202,10 +202,10 @@ D3D11_ReadShaderContents(const wstring & shaderName, vector<char> & out)
wstring fileName;

#if WINAPI_FAMILY == WINAPI_FAMILY_APP
fileName = SDL_WinRTGetInstalledLocationPath();
fileName = SDL_WinRTGetFileSystemPath(SDL_WINRT_PATH_INSTALLED_LOCATION);
fileName += L"\\SDL_VS2012_WinRT\\";
#elif WINAPI_FAMILY == WINAPI_PHONE_APP
fileName = SDL_WinRTGetInstalledLocationPath();
fileName = SDL_WinRTGetFileSystemPath(SDL_WINRT_PATH_INSTALLED_LOCATION);
fileName += L"\\";
#endif
// WinRT, TODO: test Direct3D 11.1 shader loading on Win32

0 comments on commit 893f11d

Please sign in to comment.