diff options
Diffstat (limited to 'intern/ghost/intern/GHOST_SystemPathsWin32.cpp')
-rw-r--r-- | intern/ghost/intern/GHOST_SystemPathsWin32.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/intern/ghost/intern/GHOST_SystemPathsWin32.cpp b/intern/ghost/intern/GHOST_SystemPathsWin32.cpp index 673cbcad97e..193633b5c3e 100644 --- a/intern/ghost/intern/GHOST_SystemPathsWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemPathsWin32.cpp @@ -22,6 +22,7 @@ */ #include "GHOST_SystemPathsWin32.h" +#include "GHOST_Debug.h" #ifndef _WIN32_IE # define _WIN32_IE 0x0501 @@ -76,6 +77,50 @@ const GHOST_TUns8 *GHOST_SystemPathsWin32::getUserDir(int, const char *versionst return NULL; } +const GHOST_TUns8 *GHOST_SystemPathsWin32::getUserSpecialDir(GHOST_TUserSpecialDirTypes type) const +{ + GUID folderid; + + switch (type) { + case GHOST_kUserSpecialDirDesktop: + folderid = FOLDERID_Desktop; + break; + case GHOST_kUserSpecialDirDocuments: + folderid = FOLDERID_Documents; + break; + case GHOST_kUserSpecialDirDownloads: + folderid = FOLDERID_Downloads; + break; + case GHOST_kUserSpecialDirMusic: + folderid = FOLDERID_Music; + break; + case GHOST_kUserSpecialDirPictures: + folderid = FOLDERID_Pictures; + break; + case GHOST_kUserSpecialDirVideos: + folderid = FOLDERID_Videos; + break; + default: + GHOST_ASSERT( + false, + "GHOST_SystemPathsWin32::getUserSpecialDir(): Invalid enum value for type parameter"); + return NULL; + } + + static char knownpath[MAX_PATH * 3] = {0}; + PWSTR knownpath_16 = NULL; + HRESULT hResult = SHGetKnownFolderPath(folderid, KF_FLAG_DEFAULT, NULL, &knownpath_16); + + if (hResult == S_OK) { + conv_utf_16_to_8(knownpath_16, knownpath, MAX_PATH * 3); + CoTaskMemFree(knownpath_16); + return (GHOST_TUns8 *)knownpath; + } + + CoTaskMemFree(knownpath_16); + return NULL; +} + const GHOST_TUns8 *GHOST_SystemPathsWin32::getBinaryDir() const { static char fullname[MAX_PATH * 3] = {0}; |