WinRT: added SDL_HINT_WINRT_PREF_PATH_ROOT

SDL_HINT_WINRT_PREF_PATH_ROOT allows WinRT apps to alter the path that
SDL_GetPrefPath() returns.  Setting it to "local" uses the app's
OS-defined Local folder, setting it to "roaming" uses the app's OS-defined
Roaming folder.

Roaming folder support is not available in Windows Phone 8.0.  Attempts to
make SDL_GetPrefPath() return a Roaming folder on this OS will be ignored.

Various bits of documentation on this were added to SDL_hints.h, and to
README-winrt.md
David Ludwig 2014-11-27 09:55:34 -05:00
parent 506a1efc22
commit ecc014740a
3 changed files with 63 additions and 2 deletions

View File

@ -116,6 +116,32 @@ Here is a rough list of what works, and what doens't:
Caveats
-------
#### SDL_GetPrefPath() usage
SDL_GetPrefPath() is available for use in WinRT apps, however the following
should be noted:
1. It will return different path types, by default, depending on the WinRT
platform. Windows Phone apps will default to using the app's "local" path,
whereas Windows Store (i.e. non-Phone) apps will default to using the app's
"roaming" path. This behavior can be changed by calling SDL_SetHint() with
the key, SDL_HINT_WINRT_PREF_PATH_ROOT, and a value of either "local" or
"roaming".
2. Windows Phone 8.0 does not provide apps access to a "roaming" folder.
Attempts to make SDL_GetPrefPath() return a roaming folder on Windows
Phone 8.0 will be ignored (and a path inside the "local" folder will be
used instead).
Further details on this can be found in the documentation for
SDL_HINT_WINRT_PREF_PATH_ROOT, in SDL_hints.h, as well as the docs for
SDL_WinRT_Path, SDL_WinRTGetFSPathUNICODE, and SDL_WinRTGetFSPathUTF8,
in SDL_system.h.
Setup, High-Level Steps
-----------------------

View File

@ -491,6 +491,27 @@ extern "C" {
*/
#define SDL_HINT_WINRT_HANDLE_BACK_BUTTON "SDL_WINRT_HANDLE_BACK_BUTTON"
/**
* \brief A variable that dictates what SDL_GetPrefPath() returns in WinRT apps.
*
* The variable can be set to the following values:
* "local" - Use the app's 'local' folder to store data; default for
* Windows Phone apps.
* "roaming" - Use the app's 'roaming' folder to store data; default for
* Windows Store (non-Phone) apps. On Windows Phone 8.0, this
* setting will be ignored (and the 'local' folder will be used
* instead), as the OS does not support roaming folders.
*
* Details on 'local' verses 'roaming' folders can be found on MSDN, in the
* documentation for WinRT's Windows.Storage.ApplicationData class, which is
* available at http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata
*
* The application's local and roaming paths may, alternatively, be retrieved
* via the SDL_WinRTGetFSPathUTF8() and SDL_WinRTGetFSPathUNICODE() functions,
* which are defined in SDL_system.h.
*/
#define SDL_HINT_WINRT_PREF_PATH_ROOT "SDL_WINRT_PREF_PATH_ROOT"
/**
* \brief A variable that dictates policy for fullscreen Spaces on Mac OS X.
*

View File

@ -28,6 +28,7 @@
extern "C" {
#include "SDL_filesystem.h"
#include "SDL_error.h"
#include "SDL_hints.h"
#include "SDL_stdinc.h"
#include "SDL_system.h"
#include "../../core/windows/SDL_windows.h"
@ -149,13 +150,26 @@ SDL_GetPrefPath(const char *org, const char *app)
* compatibility with Windows Phone 8.0, and with app-installs that have
* been updated from 8.0-based, to 8.1-based apps.
*/
const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_LOCAL_FOLDER);
SDL_WinRT_Path pathType = SDL_WINRT_PATH_LOCAL_FOLDER;
#else
/* A 'Roaming' folder is available on Windows 8 and 8.1. Use that.
*/
const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_ROAMING_FOLDER);
SDL_WinRT_Path pathType = SDL_WINRT_PATH_ROAMING_FOLDER;
#endif
const char * hint = SDL_GetHint(SDL_HINT_WINRT_PREF_PATH_ROOT);
if (hint) {
if (SDL_strcasecmp(hint, "local") == 0) {
pathType = SDL_WINRT_PATH_LOCAL_FOLDER;
}
#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8)
else if (SDL_strcasecmp(hint, "roaming") == 0) {
pathType = SDL_WINRT_PATH_ROAMING_FOLDER;
}
#endif
}
const char * srcPath = SDL_WinRTGetFSPathUTF8(pathType);
size_t destPathLen;
char * destPath = NULL;