WinRT: consolidated all WinRT path-retrieval functions into one function
This commit is contained in:
parent
af0c2dad3d
commit
2649db8b65
3 changed files with 80 additions and 78 deletions
|
@ -96,44 +96,46 @@ extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath();
|
||||||
/* Platform specific functions for Windows RT */
|
/* Platform specific functions for Windows RT */
|
||||||
#if defined(__WINRT__) && __WINRT__
|
#if defined(__WINRT__) && __WINRT__
|
||||||
|
|
||||||
/* Gets the path to the installed app's root directory.
|
/**
|
||||||
|
* \brief Windows RT / Windows Phone path types
|
||||||
This function may be used safely on Windows Phone 8.
|
|
||||||
*/
|
|
||||||
extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetInstalledLocationPath();
|
|
||||||
|
|
||||||
/* 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 wchar_t * SDLCALL SDL_WinRTGetLocalFolderPath();
|
typedef enum
|
||||||
|
{
|
||||||
|
/** \brief The installed app's root directory.
|
||||||
|
Files here are likely to be read-only. */
|
||||||
|
SDL_WINRT_PATH_INSTALLED_LOCATION,
|
||||||
|
|
||||||
/* Gets the path to the roaming app data store.
|
/** \brief The app's local data store. Files may be written here */
|
||||||
Files and directories that should roam to different devices can be
|
SDL_WINRT_PATH_LOCAL_FOLDER,
|
||||||
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,
|
/** \brief The app's roaming data store. Unsupported on Windows Phone.
|
||||||
as Windows Phone 8 apps do not have an accessible roaming app data
|
Files written here may be copied to other machines via a network
|
||||||
store.
|
connection.
|
||||||
|
*/
|
||||||
|
SDL_WINRT_PATH_ROAMING_FOLDER,
|
||||||
|
|
||||||
|
/** \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;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \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();
|
extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFileSystemPath(SDL_WinRT_Path pathType);
|
||||||
|
|
||||||
/* 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();
|
|
||||||
|
|
||||||
#endif /* __WINRT__ */
|
#endif /* __WINRT__ */
|
||||||
|
|
||||||
|
|
|
@ -19,53 +19,53 @@ using namespace std;
|
||||||
using namespace Windows::Storage;
|
using namespace Windows::Storage;
|
||||||
|
|
||||||
extern "C" const wchar_t *
|
extern "C" const wchar_t *
|
||||||
SDL_WinRTGetInstalledLocationPath()
|
SDL_WinRTGetFileSystemPath(SDL_WinRT_Path pathType)
|
||||||
{
|
{
|
||||||
static wstring path;
|
switch (pathType) {
|
||||||
if (path.empty()) {
|
case SDL_WINRT_PATH_INSTALLED_LOCATION:
|
||||||
path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
|
{
|
||||||
}
|
static wstring path;
|
||||||
return path.c_str();
|
if (path.empty()) {
|
||||||
}
|
path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
|
||||||
|
}
|
||||||
|
return path.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" const wchar_t *
|
case SDL_WINRT_PATH_LOCAL_FOLDER:
|
||||||
SDL_WinRTGetLocalFolderPath()
|
{
|
||||||
{
|
static wstring path;
|
||||||
static wstring path;
|
if (path.empty()) {
|
||||||
if (path.empty()) {
|
path = ApplicationData::Current->LocalFolder->Path->Data();
|
||||||
path = ApplicationData::Current->LocalFolder->Path->Data();
|
}
|
||||||
}
|
return path.c_str();
|
||||||
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
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" const wchar_t *
|
|
||||||
SDL_WinRTGetRoamingFolderPath()
|
|
||||||
{
|
|
||||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
|
||||||
SDL_Unsupported();
|
SDL_Unsupported();
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
|
||||||
static wstring path;
|
|
||||||
if (path.empty()) {
|
|
||||||
path = ApplicationData::Current->RoamingFolder->Path->Data();
|
|
||||||
}
|
|
||||||
return path.c_str();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" const wchar_t *
|
|
||||||
SDL_WinRTGetTemporaryFolderPath()
|
|
||||||
{
|
|
||||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
|
||||||
SDL_Unsupported();
|
|
||||||
return NULL;
|
|
||||||
#else
|
|
||||||
static wstring path;
|
|
||||||
if (path.empty()) {
|
|
||||||
path = ApplicationData::Current->TemporaryFolder->Path->Data();
|
|
||||||
}
|
|
||||||
return path.c_str();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __WINRT__ */
|
#endif /* __WINRT__ */
|
||||||
|
|
|
@ -202,10 +202,10 @@ D3D11_ReadShaderContents(const wstring & shaderName, vector<char> & out)
|
||||||
wstring fileName;
|
wstring fileName;
|
||||||
|
|
||||||
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
|
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
|
||||||
fileName = SDL_WinRTGetInstalledLocationPath();
|
fileName = SDL_WinRTGetFileSystemPath(SDL_WINRT_PATH_INSTALLED_LOCATION);
|
||||||
fileName += L"\\SDL_VS2012_WinRT\\";
|
fileName += L"\\SDL_VS2012_WinRT\\";
|
||||||
#elif WINAPI_FAMILY == WINAPI_PHONE_APP
|
#elif WINAPI_FAMILY == WINAPI_PHONE_APP
|
||||||
fileName = SDL_WinRTGetInstalledLocationPath();
|
fileName = SDL_WinRTGetFileSystemPath(SDL_WINRT_PATH_INSTALLED_LOCATION);
|
||||||
fileName += L"\\";
|
fileName += L"\\";
|
||||||
#endif
|
#endif
|
||||||
// WinRT, TODO: test Direct3D 11.1 shader loading on Win32
|
// WinRT, TODO: test Direct3D 11.1 shader loading on Win32
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue