aboutsummaryrefslogtreecommitdiffhomepage
path: root/osdep
diff options
context:
space:
mode:
authorGravatar James Ross-Gowan <rossymiles@gmail.com>2015-12-07 18:51:17 +1100
committerGravatar James Ross-Gowan <rossymiles@gmail.com>2015-12-20 21:06:02 +1100
commit6205d87a7f34ac4e44126dd7a2e5e71f2530a509 (patch)
treedaac2a705bab2fafbbfa3f22c205c6da132bebc8 /osdep
parent491958a724b49c2ac0d82ba2a48eede6860c1e6b (diff)
win32: path: use Known Folder IDs
CSIDLs have been deprecated in Windows Vista and are not recommended for use in new code. They have been replaced with Known Folder IDs, which are pretty much the same thing, except they use GUIDs.
Diffstat (limited to 'osdep')
-rw-r--r--osdep/path-win.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/osdep/path-win.c b/osdep/path-win.c
index a735fad069..d9042ee0e7 100644
--- a/osdep/path-win.c
+++ b/osdep/path-win.c
@@ -17,6 +17,7 @@
#include <windows.h>
#include <shlobj.h>
+#include <knownfolders.h>
#include <pthread.h>
#include "osdep/path.h"
@@ -52,20 +53,21 @@ static char *mp_get_win_exe_subdir(void *ta_ctx, const char *name)
return talloc_asprintf(ta_ctx, "%s/%s", mp_get_win_exe_dir(ta_ctx), name);
}
-static char *mp_get_win_shell_dir(void *talloc_ctx, int folder)
+static char *mp_get_win_shell_dir(void *talloc_ctx, REFKNOWNFOLDERID folder)
{
- wchar_t w_appdir[MAX_PATH + 1] = {0};
+ wchar_t *w_appdir = NULL;
- if (SHGetFolderPathW(NULL, folder|CSIDL_FLAG_CREATE, NULL,
- SHGFP_TYPE_CURRENT, w_appdir) != S_OK)
+ if (FAILED(SHGetKnownFolderPath(folder, KF_FLAG_CREATE, NULL, &w_appdir)))
return NULL;
- return mp_to_utf8(talloc_ctx, w_appdir);
+ char *appdir = mp_to_utf8(talloc_ctx, w_appdir);
+ CoTaskMemFree(w_appdir);
+ return appdir;
}
static char *mp_get_win_app_dir(void *talloc_ctx)
{
- char *path = mp_get_win_shell_dir(talloc_ctx, CSIDL_APPDATA);
+ char *path = mp_get_win_shell_dir(talloc_ctx, &FOLDERID_RoamingAppData);
return path ? mp_path_join(talloc_ctx, path, "mpv") : NULL;
}
@@ -95,6 +97,6 @@ const char *mp_get_platform_path_win(void *talloc_ctx, const char *type)
return mp_get_win_exe_subdir(talloc_ctx, "mpv");
}
if (strcmp(type, "desktop") == 0)
- return mp_get_win_shell_dir(talloc_ctx, CSIDL_DESKTOPDIRECTORY);
+ return mp_get_win_shell_dir(talloc_ctx, &FOLDERID_Desktop);
return NULL;
}