winrt: Implemented SDL_GetUserFolder() for WinRT/UWP.

main
Ryan C. Gordon 2024-04-13 08:05:16 -04:00
parent 1e369b7f33
commit 3f4ac1a3c7
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
2 changed files with 37 additions and 16 deletions

View File

@ -148,19 +148,19 @@ extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app);
*
* The folders supported per platform are:
*
* | | Windows | macOS/iOS | tvOS | Unix (XDG) | Haiku | Emscripten |
* | ----------- | ------- | --------- | ---- | ---------- | ----- | ---------- |
* | HOME | X | X | | X | X | X |
* | DESKTOP | X | X | | X | X | |
* | DOCUMENTS | X | X | | X | | |
* | DOWNLOADS | Vista+ | X | | X | | |
* | MUSIC | X | X | | X | | |
* | PICTURES | X | X | | X | | |
* | PUBLICSHARE | | X | | X | | |
* | SAVEDGAMES | Vista+ | | | | | |
* | SCREENSHOTS | Vista+ | | | | | |
* | TEMPLATES | X | X | | X | | |
* | VIDEOS | X | X* | | X | | |
* | | Windows | WinRT/UWP |macOS/iOS | tvOS | Unix (XDG) | Haiku | Emscripten |
* | ----------- | ------- | --------- |--------- | ---- | ---------- | ----- | ---------- |
* | HOME | X | X | X | | X | X | X |
* | DESKTOP | X | X | X | | X | X | |
* | DOCUMENTS | X | X | X | | X | | |
* | DOWNLOADS | Vista+ | X | X | | X | | |
* | MUSIC | X | X | X | | X | | |
* | PICTURES | X | X | X | | X | | |
* | PUBLICSHARE | | | X | | X | | |
* | SAVEDGAMES | Vista+ | | | | | | |
* | SCREENSHOTS | Vista+ | X | | | | | |
* | TEMPLATES | X | X | X | | X | | |
* | VIDEOS | X | X | X* | | X | | |
*
* Note that on macOS/iOS, the Videos folder is called "Movies".
*

View File

@ -229,11 +229,32 @@ SDL_GetPrefPath(const char *org, const char *app)
return retval;
}
/* TODO */
char *SDL_GetUserFolder(SDL_Folder folder)
{
SDL_Unsupported();
return NULL;
wstring wpath;
switch (folder) {
#define CASEPATH(sym, var) case sym: wpath = Windows::Storage::UserDataPaths::GetDefault()->var->Data(); break
CASEPATH(SDL_FOLDER_HOME, Profile);
CASEPATH(SDL_FOLDER_DESKTOP, Desktop);
CASEPATH(SDL_FOLDER_DOCUMENTS, Documents);
CASEPATH(SDL_FOLDER_DOWNLOADS, Downloads);
CASEPATH(SDL_FOLDER_MUSIC, Music);
CASEPATH(SDL_FOLDER_PICTURES, Pictures);
CASEPATH(SDL_FOLDER_SCREENSHOTS, Screenshots);
CASEPATH(SDL_FOLDER_TEMPLATES, Templates);
CASEPATH(SDL_FOLDER_VIDEOS, Videos);
#undef CASEPATH
#define UNSUPPPORTED_CASEPATH(sym) SDL_SetError("The %s folder is unsupported on WinRT", #sym); return NULL;
UNSUPPPORTED_CASEPATH(SDL_FOLDER_PUBLICSHARE);
UNSUPPPORTED_CASEPATH(SDL_FOLDER_SAVEDGAMES);
#undef UNSUPPPORTED_CASEPATH
default:
SDL_SetError("Invalid SDL_Folder: %d", (int)folder);
return NULL;
};
return WIN_StringToUTF8(wpath.c_str());
}
#endif /* SDL_PLATFORM_WINRT */