diff --git a/include/SDL3/SDL_filesystem.h b/include/SDL3/SDL_filesystem.h index 268fae02e..9cefc7555 100644 --- a/include/SDL3/SDL_filesystem.h +++ b/include/SDL3/SDL_filesystem.h @@ -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". * diff --git a/src/filesystem/winrt/SDL_sysfilesystem.cpp b/src/filesystem/winrt/SDL_sysfilesystem.cpp index a21679993..d903e2a50 100644 --- a/src/filesystem/winrt/SDL_sysfilesystem.cpp +++ b/src/filesystem/winrt/SDL_sysfilesystem.cpp @@ -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 */