From 98d5dea18a098eaf54d845711fdbbfb15a1eb991 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 28 Dec 2006 15:47:42 +0000 Subject: [PATCH] : Use only the wide character API here, too. 2006-12-28 Tor Lillqvist * glib/gutils.c (get_windows_directory_root): : Use only the wide character API here, too. --- ChangeLog | 3 ++- glib/gutils.c | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2f6445..dc287cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2006-12-28 Tor Lillqvist - * glib/gutils.h (G_WIN32_DLLMAIN_FOR_DLL_NAME): Use only the wide + * glib/gutils.h (G_WIN32_DLLMAIN_FOR_DLL_NAME) + * glib/gutils.c (get_windows_directory_root): : Use only the wide character API here, too. * glib/gslice.c: Make it compile on Win32 without pthreads: Use a diff --git a/glib/gutils.c b/glib/gutils.c index 1eee8b2..d756679 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -1415,18 +1415,24 @@ get_special_folder (int csidl) static char * get_windows_directory_root (void) { - char windowsdir[MAX_PATH]; + wchar_t wwindowsdir[MAX_PATH]; - if (GetWindowsDirectory (windowsdir, sizeof (windowsdir))) + if (GetWindowsDirectoryW (wwindowsdir, G_N_ELEMENTS (wwindowsdir))) { /* Usually X:\Windows, but in terminal server environments * might be an UNC path, AFAIK. */ - char *p = (char *) g_path_skip_root (windowsdir); + char *windowsdir = g_utf16_to_utf8 (wwindowsdir, -1, NULL, NULL, NULL); + char *p; + + if (windowsdir == NULL) + return g_strdup ("C:\\"); + + p = (char *) g_path_skip_root (windowsdir); if (G_IS_DIR_SEPARATOR (p[-1]) && p[-2] != ':') p--; *p = '\0'; - return g_strdup (windowsdir); + return windowsdir; } else return g_strdup ("C:\\"); -- 2.7.4