[vlc-commits] [Git][videolan/vlc][master] 2 commits: Win32: use GetKnownFolders API for dirs
François Cartegnie (@fcartegnie)
gitlab at videolan.org
Tue Dec 27 15:40:44 UTC 2022
François Cartegnie pushed to branch master at VideoLAN / VLC
Commits:
53219ebd by Prince Gupta at 2022-12-27T15:26:17+00:00
Win32: use GetKnownFolders API for dirs
- - - - -
73ea7439 by Prince Gupta at 2022-12-27T15:26:17+00:00
Win32: correctly handle VLC_DISKTOP_DIR and VLC_DOWNLOAD_DIR
- - - - -
2 changed files:
- src/Makefile.am
- src/win32/dirs.c
Changes:
=====================================
src/Makefile.am
=====================================
@@ -431,7 +431,7 @@ if HAVE_WINSTORE
libvlccore_la_SOURCES += posix/timer.c win32/dirs-uap.c
else
libvlccore_la_SOURCES += win32/timer.c win32/dirs.c win32/spawn.c
-libvlccore_la_LIBADD += -lwinmm
+libvlccore_la_LIBADD += -lwinmm -lole32 -luuid
endif
libvlccore_la_LIBADD += -lbcrypt
endif
=====================================
src/win32/dirs.c
=====================================
@@ -104,14 +104,19 @@ char *config_GetSysPath(vlc_sysdir_t type, const char *filename)
return path;
}
-static char *config_GetShellDir (int csidl)
+static char *config_GetKnownFolder (KNOWNFOLDERID id)
{
- wchar_t wdir[MAX_PATH];
+ PWSTR wdir = NULL;
- if (SHGetFolderPathW (NULL, csidl | CSIDL_FLAG_CREATE,
- NULL, SHGFP_TYPE_CURRENT, wdir ) == S_OK)
- return FromWide (wdir);
- return NULL;
+ const HRESULT hr = SHGetKnownFolderPath (&id, 0, NULL, &wdir);
+
+ char *result = NULL;
+
+ if ( hr == S_OK )
+ result = FromWide(wdir);
+
+ CoTaskMemFree(wdir);
+ return result;
}
static char *config_GetAppDir (void)
@@ -132,7 +137,7 @@ static char *config_GetAppDir (void)
}
char *psz_dir;
- char *psz_parent = config_GetShellDir (CSIDL_APPDATA);
+ char *psz_parent = config_GetKnownFolder (FOLDERID_RoamingAppData);
if (psz_parent == NULL
|| asprintf (&psz_dir, "%s\\vlc", psz_parent) == -1)
@@ -141,30 +146,31 @@ static char *config_GetAppDir (void)
return psz_dir;
}
-#warning FIXME Use known folders on Vista and above
char *config_GetUserDir (vlc_userdir_t type)
{
switch (type)
{
case VLC_HOME_DIR:
- return config_GetShellDir (CSIDL_PERSONAL);
+ return config_GetKnownFolder (FOLDERID_Documents);
case VLC_CONFIG_DIR:
case VLC_USERDATA_DIR:
return config_GetAppDir ();
case VLC_CACHE_DIR:
return config_GetAppDir ();
case VLC_DESKTOP_DIR:
+ return config_GetKnownFolder (FOLDERID_Desktop);
case VLC_DOWNLOAD_DIR:
+ return config_GetKnownFolder (FOLDERID_Downloads);
case VLC_TEMPLATES_DIR:
case VLC_PUBLICSHARE_DIR:
case VLC_DOCUMENTS_DIR:
return config_GetUserDir(VLC_HOME_DIR);
case VLC_MUSIC_DIR:
- return config_GetShellDir (CSIDL_MYMUSIC);
+ return config_GetKnownFolder (FOLDERID_Music);
case VLC_PICTURES_DIR:
- return config_GetShellDir (CSIDL_MYPICTURES);
+ return config_GetKnownFolder (FOLDERID_Pictures);
case VLC_VIDEOS_DIR:
- return config_GetShellDir (CSIDL_MYVIDEO);
+ return config_GetKnownFolder (FOLDERID_Videos);
}
vlc_assert_unreachable ();
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/485c3f02f5a75f574f4e1ba7fc68674cf5bf5baf...73ea74393d29293e00ed4125faf1753ac632f3ba
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/485c3f02f5a75f574f4e1ba7fc68674cf5bf5baf...73ea74393d29293e00ed4125faf1753ac632f3ba
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list