: Use only the wide character API here, too.

2006-12-28  Tor Lillqvist  <tml@novell.com>

	* glib/gutils.c (get_windows_directory_root): : Use only the wide
	character API here, too.
This commit is contained in:
Tor Lillqvist 2006-12-28 15:47:42 +00:00 committed by Tor Lillqvist
parent a45be29beb
commit 98d5dea18a
2 changed files with 12 additions and 5 deletions

View File

@ -1,6 +1,7 @@
2006-12-28 Tor Lillqvist <tml@novell.com> 2006-12-28 Tor Lillqvist <tml@novell.com>
* 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. character API here, too.
* glib/gslice.c: Make it compile on Win32 without pthreads: Use a * glib/gslice.c: Make it compile on Win32 without pthreads: Use a

View File

@ -1415,18 +1415,24 @@ get_special_folder (int csidl)
static char * static char *
get_windows_directory_root (void) 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 /* Usually X:\Windows, but in terminal server environments
* might be an UNC path, AFAIK. * 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] != ':') if (G_IS_DIR_SEPARATOR (p[-1]) && p[-2] != ':')
p--; p--;
*p = '\0'; *p = '\0';
return g_strdup (windowsdir); return windowsdir;
} }
else else
return g_strdup ("C:\\"); return g_strdup ("C:\\");