X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=eglib%2Fsrc%2Fgmisc-win32.c;h=4aac0ef69460fe70c432dfb78f8fcfd2bd931f5a;hb=23a69556ded315d102337bf13971411188e26bcd;hp=f9fdb668f2d89d842c411e7af76d9d4a410ccfb9;hpb=a342bb00ca0e7b7c5267845f45b928055f412b2c;p=mono.git diff --git a/eglib/src/gmisc-win32.c b/eglib/src/gmisc-win32.c index f9fdb668f2d..4aac0ef6946 100644 --- a/eglib/src/gmisc-win32.c +++ b/eglib/src/gmisc-win32.c @@ -101,27 +101,6 @@ g_win32_getlocale(void) ccBuf += GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9); return g_strdup (buf); } - -#else /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */ - -gchar* -g_win32_getlocale(void) -{ - gunichar2 buf[19]; - gint ccBuf = GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SISO639LANGNAME, buf, 9); - assert (ccBuf <= 9); - if (ccBuf != 0) { - buf[ccBuf - 1] = L'-'; - ccBuf = GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9); - assert (ccBuf <= 9); - } - - // Check for GetLocaleInfoEx failure. - if (ccBuf == 0) - buf[0] = L'\0'; - - return u16to8 (buf); -} #endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */ gboolean @@ -142,20 +121,35 @@ g_path_is_absolute (const char *filename) return FALSE; } -const gchar * -g_get_home_dir (void) -{ - gchar *home_dir = NULL; - #if _MSC_VER && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +static gchar* +g_get_known_folder_path (void) +{ + gchar *folder_path = NULL; PWSTR profile_path = NULL; HRESULT hr = SHGetKnownFolderPath (&FOLDERID_Profile, KF_FLAG_DEFAULT, NULL, &profile_path); if (SUCCEEDED(hr)) { - home_dir = u16to8 (profile_path); + folder_path = u16to8 (profile_path); CoTaskMemFree (profile_path); } + + return folder_path; +} + +#else + +static inline gchar * +g_get_known_folder_path (void) +{ + return NULL; +} #endif +const gchar * +g_get_home_dir (void) +{ + gchar *home_dir = g_get_known_folder_path (); + if (!home_dir) { home_dir = (gchar *) g_getenv ("USERPROFILE"); }