glib r6883 - in trunk: . glib
- From: tml svn gnome org
- To: svn-commits-list gnome org
- Subject: glib r6883 - in trunk: . glib
- Date: Mon, 12 May 2008 07:58:50 +0100 (BST)
Author: tml
Date: Mon May 12 06:58:50 2008
New Revision: 6883
URL: http://svn.gnome.org/viewvc/glib?rev=6883&view=rev
Log:
2008-05-12 Tor Lillqvist <tml novell com>
Bug 530457 - G_USER_DIRECTORY_DOWNLOAD folder improperly mapped
* glib/gutils.c (load_user_special_dirs): When running on Vista or
later, use SHGetKnownFolderPath() to get the FOLDERID_Downloads
folder for G_USER_DIRECTORY_DOWNLOAD, and FOLDERID_Public for
G_USER_DIRECTORY_PUBLIC_SHARE.
Modified:
trunk/ChangeLog
trunk/glib/gutils.c
Modified: trunk/glib/gutils.c
==============================================================================
--- trunk/glib/gutils.c (original)
+++ trunk/glib/gutils.c Mon May 12 06:58:50 2008
@@ -2225,12 +2225,55 @@
static void
load_user_special_dirs (void)
{
+ typedef HRESULT (WINAPI *t_SHGetKnownFolderPath) (const GUID *rfid,
+ DWORD dwFlags,
+ HANDLE hToken,
+ PWSTR *ppszPath);
+ t_SHGetKnownFolderPath p_SHGetKnownFolderPath;
+ static const GUID FOLDERID_Downloads =
+ { 0x374de290, 0x123f, 0x4565, { 0x91, 0x64, 0x39, 0xc4, 0x92, 0x5e, 0x46, 0x7b } };
+ static const GUID FOLDERID_Public =
+ { 0xDFDF76A2, 0xC82A, 0x4D63, { 0x90, 0x6A, 0x56, 0x44, 0xAC, 0x45, 0x73, 0x85 } };
+ wchar_t *wcp;
+
+ p_SHGetKnownFolderPath = (t_SHGetKnownFolderPath) GetProcAddress (LoadLibrary ("shell32.dll"),
+ "SHGetKnownFolderPath");
+
g_user_special_dirs[G_USER_DIRECTORY_DESKTOP] = get_special_folder (CSIDL_DESKTOPDIRECTORY);
g_user_special_dirs[G_USER_DIRECTORY_DOCUMENTS] = get_special_folder (CSIDL_PERSONAL);
- g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = get_special_folder (CSIDL_DESKTOPDIRECTORY); /* XXX correct ? */
+
+ if (p_SHGetKnownFolderPath == NULL)
+ {
+ g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = get_special_folder (CSIDL_DESKTOPDIRECTORY);
+ }
+ else
+ {
+ wcp = NULL;
+ (*p_SHGetKnownFolderPath) (&FOLDERID_Downloads, 0, NULL, &wcp);
+ g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = g_utf16_to_utf8 (wcp, -1, NULL, NULL, NULL);
+ if (g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] == NULL)
+ g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = get_special_folder (CSIDL_DESKTOPDIRECTORY);
+ CoTaskMemFree (wcp);
+ }
+
g_user_special_dirs[G_USER_DIRECTORY_MUSIC] = get_special_folder (CSIDL_MYMUSIC);
g_user_special_dirs[G_USER_DIRECTORY_PICTURES] = get_special_folder (CSIDL_MYPICTURES);
- g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = get_special_folder (CSIDL_COMMON_DOCUMENTS); /* XXX correct ? */
+
+ if (p_SHGetKnownFolderPath == NULL)
+ {
+ /* XXX */
+ g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = get_special_folder (CSIDL_COMMON_DOCUMENTS);
+ }
+ else
+ {
+ wcp = NULL;
+ (*p_SHGetKnownFolderPath) (&FOLDERID_Public, 0, NULL, &wcp);
+ g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = g_utf16_to_utf8 (wcp, -1, NULL, NULL, NULL);
+ if (g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] == NULL)
+ g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = get_special_folder (CSIDL_COMMON_DOCUMENTS);
+ CoTaskMemFree (wcp);
+ }
+
g_user_special_dirs[G_USER_DIRECTORY_TEMPLATES] = get_special_folder (CSIDL_TEMPLATES);
g_user_special_dirs[G_USER_DIRECTORY_VIDEOS] = get_special_folder (CSIDL_MYVIDEO);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]