Remove support for Windows 9x/ME, as will be done also in Pango and GTK+.

2006-08-29  Tor Lillqvist  <tml@novell.com>

	Remove support for Windows 9x/ME, as will be done also in Pango
	and GTK+. GTK+ hasn't worked on Win9x since 2.6 or 2.8 anyway, so
	it's pretty pointless to keep the Win9x code in here either. If
	somebody is interested, the code can always be found in older GLib
	versions, and in CVS.

	* glib/gdir.c
	* glib/gfileutils.c
	* glib/gspawn-win32-helper.c
	* glib/gspawn-win32.c
	* glib/gstdio.c
	* glib/gutils.c
	* glib/gwin32.c
	* glib/gwin32.h: Remove the G_WIN32_IS_NT_BASED() and
	G_WIN32_HAVE_WIDECHAR_API() tests and their false (Win9x)
	branches, and any variables or static functions used only by the
	Win9x branches.

	* glib/gwin32.c (g_win32_windows_version_init): Call g_error() if
	run on Win9x.
This commit is contained in:
Tor Lillqvist 2006-08-29 22:45:00 +00:00 committed by Tor Lillqvist
parent 08e3a830fb
commit da422c0060
11 changed files with 581 additions and 1381 deletions

View File

@ -1,3 +1,26 @@
2006-08-29 Tor Lillqvist <tml@novell.com>
Remove support for Windows 9x/ME, as will be done also in Pango
and GTK+. GTK+ hasn't worked on Win9x since 2.6 or 2.8 anyway, so
it's pretty pointless to keep the Win9x code in here either. If
somebody is interested, the code can always be found in older GLib
versions, and in CVS.
* glib/gdir.c
* glib/gfileutils.c
* glib/gspawn-win32-helper.c
* glib/gspawn-win32.c
* glib/gstdio.c
* glib/gutils.c
* glib/gwin32.c
* glib/gwin32.h: Remove the G_WIN32_IS_NT_BASED() and
G_WIN32_HAVE_WIDECHAR_API() tests and their false (Win9x)
branches, and any variables or static functions used only by the
Win9x branches.
* glib/gwin32.c (g_win32_windows_version_init): Call g_error() if
run on Win9x.
2006-08-27 Matthias Clasen <mclasen@redhat.com>
* configure.in: Fix pthread compiler flag detection.

View File

@ -25,7 +25,8 @@
#include "config.h"
#include <errno.h>
#include <string.h> /* strcmp */
#include <string.h>
#include <sys/stat.h>
#ifdef HAVE_DIRENT_H
#include <sys/types.h>
@ -41,12 +42,11 @@
struct _GDir
{
union {
DIR *dirp;
#ifdef G_OS_WIN32
_WDIR *wdirp;
#else
DIR *dirp;
#endif
} u;
#ifdef G_OS_WIN32
gchar utf8_buf[FILENAME_MAX*4];
#endif
@ -74,44 +74,27 @@ g_dir_open (const gchar *path,
GError **error)
{
GDir *dir;
#ifndef G_OS_WIN32
#ifdef G_OS_WIN32
wchar_t *wpath;
#else
gchar *utf8_path;
#endif
g_return_val_if_fail (path != NULL, NULL);
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wpath = g_utf8_to_utf16 (path, -1, NULL, NULL, error);
wpath = g_utf8_to_utf16 (path, -1, NULL, NULL, error);
if (wpath == NULL)
return NULL;
dir = g_new (GDir, 1);
dir->u.wdirp = _wopendir (wpath);
dir->wdirp = _wopendir (wpath);
g_free (wpath);
if (dir->u.wdirp)
if (dir->wdirp)
return dir;
}
else
{
gchar *cp_path = g_locale_from_utf8 (path, -1, NULL, NULL, error);
if (cp_path == NULL)
return NULL;
dir = g_new (GDir, 1);
dir->u.dirp = opendir (cp_path);
g_free (cp_path);
if (dir->u.dirp)
return dir;
}
/* error case */
@ -127,9 +110,9 @@ g_dir_open (const gchar *path,
#else
dir = g_new (GDir, 1);
dir->u.dirp = opendir (path);
dir->dirp = opendir (path);
if (dir->u.dirp)
if (dir->dirp)
return dir;
/* error case */
@ -193,23 +176,23 @@ g_dir_open (const gchar *path,
G_CONST_RETURN gchar*
g_dir_read_name (GDir *dir)
{
#ifdef G_OS_WIN32
gchar *utf8_name;
struct _wdirent *wentry;
#else
struct dirent *entry;
#endif
g_return_val_if_fail (dir != NULL, NULL);
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
gchar *utf8_name;
struct _wdirent *wentry;
while (1)
{
wentry = _wreaddir (dir->u.wdirp);
wentry = _wreaddir (dir->wdirp);
while (wentry
&& (0 == wcscmp (wentry->d_name, L".") ||
0 == wcscmp (wentry->d_name, L"..")))
wentry = _wreaddir (dir->u.wdirp);
wentry = _wreaddir (dir->wdirp);
if (wentry == NULL)
return NULL;
@ -224,39 +207,12 @@ g_dir_read_name (GDir *dir)
return dir->utf8_buf;
}
}
else
{
while (1)
{
gchar *utf8_name;
entry = readdir (dir->u.dirp);
while (entry
&& (0 == strcmp (entry->d_name, ".") ||
0 == strcmp (entry->d_name, "..")))
entry = readdir (dir->u.dirp);
if (entry == NULL)
return NULL;
utf8_name = g_locale_to_utf8 (entry->d_name, -1, NULL, NULL, NULL);
if (utf8_name != NULL)
{
strcpy (dir->utf8_buf, utf8_name);
g_free (utf8_name);
return dir->utf8_buf;
}
}
}
#else
entry = readdir (dir->u.dirp);
entry = readdir (dir->dirp);
while (entry
&& (0 == strcmp (entry->d_name, ".") ||
0 == strcmp (entry->d_name, "..")))
entry = readdir (dir->u.dirp);
entry = readdir (dir->dirp);
if (entry)
return entry->d_name;
@ -311,14 +267,10 @@ g_dir_rewind (GDir *dir)
g_return_if_fail (dir != NULL);
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
_wrewinddir (dir->u.wdirp);
return;
}
_wrewinddir (dir->wdirp);
#else
rewinddir (dir->dirp);
#endif
rewinddir (dir->u.dirp);
}
/**
@ -333,15 +285,10 @@ g_dir_close (GDir *dir)
g_return_if_fail (dir != NULL);
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
_wclosedir (dir->u.wdirp);
g_free (dir);
return;
}
_wclosedir (dir->wdirp);
#else
closedir (dir->dirp);
#endif
closedir (dir->u.dirp);
g_free (dir);
}

View File

@ -191,9 +191,6 @@ g_file_test (const gchar *filename,
# define FILE_ATTRIBUTE_DEVICE 64
# endif
int attributes;
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
if (wfilename == NULL)
@ -202,18 +199,6 @@ g_file_test (const gchar *filename,
attributes = GetFileAttributesW (wfilename);
g_free (wfilename);
}
else
{
gchar *cpfilename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
if (cpfilename == NULL)
return FALSE;
attributes = GetFileAttributesA (cpfilename);
g_free (cpfilename);
}
if (attributes == INVALID_FILE_ATTRIBUTES)
return FALSE;

View File

@ -160,7 +160,6 @@ WinMain (struct HINSTANCE__ *hInstance,
int no_error = CHILD_NO_ERROR;
int zero = 0;
gint argv_zero_offset = ARG_PROGRAM;
gchar **new_argv;
wchar_t **new_wargv;
int argc;
wchar_t **wargv, **wenvp;
@ -168,8 +167,6 @@ WinMain (struct HINSTANCE__ *hInstance,
g_assert (__argc >= ARG_COUNT);
if (G_WIN32_HAVE_WIDECHAR_API ())
{
/* Fetch the wide-char argument vector */
__wgetmainargs (&argc, &wargv, &wenvp, 0, &si);
@ -178,7 +175,6 @@ WinMain (struct HINSTANCE__ *hInstance,
* fd numbers in __argv, as we know those are just ASCII anyway.
*/
g_assert (argc == __argc);
}
/* argv[ARG_CHILD_ERR_REPORT] is the file descriptor number onto
* which write error messages.
@ -266,10 +262,7 @@ WinMain (struct HINSTANCE__ *hInstance,
if (__argv[ARG_WORKING_DIRECTORY][0] == '-' &&
__argv[ARG_WORKING_DIRECTORY][1] == 0)
; /* Nothing */
else if ((G_WIN32_HAVE_WIDECHAR_API () &&
_wchdir (wargv[ARG_WORKING_DIRECTORY]) < 0) ||
(!G_WIN32_HAVE_WIDECHAR_API () &&
chdir (__argv[ARG_WORKING_DIRECTORY]) < 0))
else if (_wchdir (wargv[ARG_WORKING_DIRECTORY]) < 0)
write_err_and_exit (child_err_report_fd, CHILD_CHDIR_FAILED);
/* __argv[ARG_CLOSE_DESCRIPTORS] is "y" if file descriptors from 3
@ -297,24 +290,12 @@ WinMain (struct HINSTANCE__ *hInstance,
/* For the program name passed to spawnv(), don't use the quoted
* version.
*/
if (G_WIN32_HAVE_WIDECHAR_API ())
{
protect_wargv (wargv + argv_zero_offset, &new_wargv);
if (__argv[ARG_USE_PATH][0] == 'y')
handle = _wspawnvp (mode, wargv[ARG_PROGRAM], (const wchar_t **) new_wargv);
else
handle = _wspawnv (mode, wargv[ARG_PROGRAM], (const wchar_t **) new_wargv);
}
else
{
protect_argv (__argv + argv_zero_offset, &new_argv);
if (__argv[ARG_USE_PATH][0] == 'y')
handle = spawnvp (mode, __argv[ARG_PROGRAM], (const char **) new_argv);
else
handle = spawnv (mode, __argv[ARG_PROGRAM], (const char **) new_argv);
}
saved_errno = errno;

View File

@ -108,6 +108,10 @@ enum {
ARG_COUNT = ARG_PROGRAM
};
#ifndef GSPAWN_HELPER
#define HELPER_PROCESS "gspawn-win32-helper"
static gchar *
protect_argv_string (const gchar *string)
{
@ -192,10 +196,6 @@ protect_argv (gchar **argv,
return argc;
}
#ifndef GSPAWN_HELPER
#define HELPER_PROCESS "gspawn-win32-helper"
GQuark
g_spawn_error_quark (void)
{
@ -400,43 +400,6 @@ utf8_charv_to_wcharv (char **utf8_charv,
return TRUE;
}
static gboolean
utf8_charv_to_cp_charv (char **utf8_charv,
gchar ***cp_charv,
int *error_index,
GError **error)
{
char **retval = NULL;
*cp_charv = NULL;
if (utf8_charv != NULL)
{
int n = 0, i;
while (utf8_charv[n])
n++;
retval = g_new (char *, n + 1);
for (i = 0; i < n; i++)
{
retval[i] = g_locale_from_utf8 (utf8_charv[i], -1, NULL, NULL, error);
if (retval[i] == NULL)
{
if (error_index)
*error_index = i;
while (i)
g_free (retval[--i]);
g_free (retval);
return FALSE;
}
}
retval[n] = NULL;
}
*cp_charv = retval;
return TRUE;
}
static gboolean
do_spawn_directly (gint *exit_status,
gboolean do_return_handle,
@ -455,11 +418,9 @@ do_spawn_directly (gint *exit_status,
int saved_errno;
GError *conv_error = NULL;
gint conv_error_index;
wchar_t *wargv0, **wargv, **wenvp;
new_argv = (flags & G_SPAWN_FILE_AND_ARGV_ZERO) ? protected_argv + 1 : protected_argv;
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wargv0, **wargv, **wenvp;
wargv0 = g_utf8_to_utf16 (argv[0], -1, NULL, NULL, &conv_error);
if (wargv0 == NULL)
@ -512,63 +473,6 @@ do_spawn_directly (gint *exit_status,
g_free (wargv0);
g_strfreev ((gchar **) wargv);
g_strfreev ((gchar **) wenvp);
}
else
{
char *cpargv0, **cpargv, **cpenvp;
cpargv0 = g_locale_from_utf8 (argv[0], -1, NULL, NULL, &conv_error);
if (cpargv0 == NULL)
{
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid program name: %s"),
conv_error->message);
g_error_free (conv_error);
return FALSE;
}
if (!utf8_charv_to_cp_charv (new_argv, &cpargv, &conv_error_index, &conv_error))
{
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid string in argument vector at %d: %s"),
conv_error_index, conv_error->message);
g_error_free (conv_error);
g_free (cpargv0);
return FALSE;
}
if (!utf8_charv_to_cp_charv (envp, &cpenvp, NULL, &conv_error))
{
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid string in environment: %s"),
conv_error->message);
g_error_free (conv_error);
g_free (cpargv0);
g_strfreev (cpargv);
return FALSE;
}
if (child_setup)
(* child_setup) (user_data);
if (flags & G_SPAWN_SEARCH_PATH)
if (cpenvp != NULL)
rc = spawnvpe (mode, cpargv0, (const char **) cpargv, (const char **) cpenvp);
else
rc = spawnvp (mode, cpargv0, (const char **) cpargv);
else
if (envp != NULL)
rc = spawnve (mode, cpargv0, (const char **) cpargv, (const char **) cpenvp);
else
rc = spawnv (mode, cpargv0, (const char **) cpargv);
g_free (cpargv0);
g_strfreev (cpargv);
g_strfreev (cpenvp);
}
saved_errno = errno;
@ -630,6 +534,7 @@ do_spawn_with_pipes (gint *exit_status,
gint conv_error_index;
gchar *helper_process;
CONSOLE_CURSOR_INFO cursor_info;
wchar_t *whelper, **wargv, **wenvp;
SETUP_DEBUG();
@ -761,10 +666,7 @@ do_spawn_with_pipes (gint *exit_status,
g_print ("argv[%d]: %s\n", i, (new_argv[i] ? new_argv[i] : "NULL"));
}
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *whelper = g_utf8_to_utf16 (helper_process, -1, NULL, NULL, NULL);
wchar_t **wargv, **wenvp;
whelper = g_utf8_to_utf16 (helper_process, -1, NULL, NULL, NULL);
if (!utf8_charv_to_wcharv (new_argv, &wargv, &conv_error_index, &conv_error))
{
@ -816,56 +718,6 @@ do_spawn_with_pipes (gint *exit_status,
g_free (whelper);
g_strfreev ((gchar **) wargv);
g_strfreev ((gchar **) wenvp);
}
else
{
char **cpargv, **cpenvp;
if (!utf8_charv_to_cp_charv (new_argv, &cpargv, &conv_error_index, &conv_error))
{
if (conv_error_index == ARG_WORKING_DIRECTORY)
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_CHDIR,
_("Invalid working directory: %s"),
conv_error->message);
else
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid string in argument vector at %d: %s"),
conv_error_index - ARG_PROGRAM, conv_error->message);
g_error_free (conv_error);
g_strfreev (protected_argv);
g_free (new_argv[ARG_WORKING_DIRECTORY]);
g_free (new_argv);
return FALSE;
}
if (!utf8_charv_to_cp_charv (envp, &cpenvp, NULL, &conv_error))
{
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Invalid string in environment: %s"),
conv_error->message);
g_error_free (conv_error);
g_strfreev (protected_argv);
g_free (new_argv[ARG_WORKING_DIRECTORY]);
g_free (new_argv);
g_strfreev (cpargv);
return FALSE;
}
if (child_setup)
(* child_setup) (user_data);
if (cpenvp != NULL)
rc = spawnvpe (P_NOWAIT, helper_process, (const char **) cpargv, (const char **) cpenvp);
else
rc = spawnvp (P_NOWAIT, helper_process, (const char **) cpargv);
saved_errno = errno;
g_strfreev (cpargv);
g_strfreev (cpenvp);
}
/* Close the other process's ends of the pipes in this process,
* otherwise the reader will never get EOF.

View File

@ -74,8 +74,6 @@ g_access (const gchar *filename,
int mode)
{
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
@ -93,27 +91,6 @@ g_access (const gchar *filename,
errno = save_errno;
return retval;
}
else
{
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
if (cp_filename == NULL)
{
errno = EINVAL;
return -1;
}
retval = access (cp_filename, mode);
save_errno = errno;
g_free (cp_filename);
errno = save_errno;
return retval;
}
#else
return access (filename, mode);
#endif
@ -143,8 +120,6 @@ g_chmod (const gchar *filename,
int mode)
{
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
@ -162,27 +137,6 @@ g_chmod (const gchar *filename,
errno = save_errno;
return retval;
}
else
{
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
if (cp_filename == NULL)
{
errno = EINVAL;
return -1;
}
retval = chmod (cp_filename, mode);
save_errno = errno;
g_free (cp_filename);
errno = save_errno;
return retval;
}
#else
return chmod (filename, mode);
#endif
@ -214,8 +168,6 @@ g_open (const gchar *filename,
int mode)
{
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
@ -233,27 +185,6 @@ g_open (const gchar *filename,
errno = save_errno;
return retval;
}
else
{
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
if (cp_filename == NULL)
{
errno = EINVAL;
return -1;
}
retval = open (cp_filename, flags, mode);
save_errno = errno;
g_free (cp_filename);
errno = save_errno;
return retval;
}
#else
return open (filename, flags, mode);
#endif
@ -283,8 +214,6 @@ g_creat (const gchar *filename,
int mode)
{
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
@ -302,27 +231,6 @@ g_creat (const gchar *filename,
errno = save_errno;
return retval;
}
else
{
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
if (cp_filename == NULL)
{
errno = EINVAL;
return -1;
}
retval = creat (cp_filename, mode);
save_errno = errno;
g_free (cp_filename);
errno = save_errno;
return retval;
}
#else
return creat (filename, mode);
#endif
@ -350,8 +258,6 @@ g_rename (const gchar *oldfilename,
const gchar *newfilename)
{
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *woldfilename = g_utf8_to_utf16 (oldfilename, -1, NULL, NULL, NULL);
wchar_t *wnewfilename;
int retval;
@ -398,38 +304,6 @@ g_rename (const gchar *oldfilename,
errno = save_errno;
return retval;
}
else
{
gchar *cp_oldfilename = g_locale_from_utf8 (oldfilename, -1, NULL, NULL, NULL);
gchar *cp_newfilename;
int retval;
int save_errno;
if (cp_oldfilename == NULL)
{
errno = EINVAL;
return -1;
}
cp_newfilename = g_locale_from_utf8 (newfilename, -1, NULL, NULL, NULL);
if (cp_newfilename == NULL)
{
g_free (cp_oldfilename);
errno = EINVAL;
return -1;
}
retval = rename (cp_oldfilename, cp_newfilename);
save_errno = errno;
g_free (cp_oldfilename);
g_free (cp_newfilename);
errno = save_errno;
return retval;
}
#else
return rename (oldfilename, newfilename);
#endif
@ -455,8 +329,6 @@ g_mkdir (const gchar *filename,
int mode)
{
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
@ -474,27 +346,6 @@ g_mkdir (const gchar *filename,
errno = save_errno;
return retval;
}
else
{
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
if (cp_filename == NULL)
{
errno = EINVAL;
return -1;
}
retval = mkdir (cp_filename);
save_errno = errno;
g_free (cp_filename);
errno = save_errno;
return retval;
}
#else
return mkdir (filename, mode);
#endif
@ -517,8 +368,6 @@ int
g_chdir (const gchar *path)
{
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wpath = g_utf8_to_utf16 (path, -1, NULL, NULL, NULL);
int retval;
int save_errno;
@ -536,27 +385,6 @@ g_chdir (const gchar *path)
errno = save_errno;
return retval;
}
else
{
gchar *cp_path = g_locale_from_utf8 (path, -1, NULL, NULL, NULL);
int retval;
int save_errno;
if (cp_path == NULL)
{
errno = EINVAL;
return -1;
}
retval = chdir (cp_path);
save_errno = errno;
g_free (cp_path);
errno = save_errno;
return retval;
}
#else
return chdir (path);
#endif
@ -583,8 +411,6 @@ g_stat (const gchar *filename,
struct stat *buf)
{
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
@ -610,35 +436,6 @@ g_stat (const gchar *filename,
errno = save_errno;
return retval;
}
else
{
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
int len;
if (cp_filename == NULL)
{
errno = EINVAL;
return -1;
}
len = strlen (cp_filename);
while (len > 0 && G_IS_DIR_SEPARATOR (cp_filename[len-1]))
len--;
if (len > 0 &&
(!g_path_is_absolute (filename) || len > g_path_skip_root (filename) - filename))
cp_filename[len] = '\0';
retval = stat (cp_filename, buf);
save_errno = errno;
g_free (cp_filename);
errno = save_errno;
return retval;
}
#else
return stat (filename, buf);
#endif
@ -697,8 +494,6 @@ int
g_unlink (const gchar *filename)
{
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
@ -716,27 +511,6 @@ g_unlink (const gchar *filename)
errno = save_errno;
return retval;
}
else
{
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
if (cp_filename == NULL)
{
errno = EINVAL;
return -1;
}
retval = unlink (cp_filename);
save_errno = errno;
g_free (cp_filename);
errno = save_errno;
return retval;
}
#else
return unlink (filename);
#endif
@ -772,8 +546,6 @@ int
g_remove (const gchar *filename)
{
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
@ -793,29 +565,6 @@ g_remove (const gchar *filename)
errno = save_errno;
return retval;
}
else
{
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
if (cp_filename == NULL)
{
errno = EINVAL;
return -1;
}
retval = remove (cp_filename);
if (retval == -1)
retval = rmdir (cp_filename);
save_errno = errno;
g_free (cp_filename);
errno = save_errno;
return retval;
}
#else
return remove (filename);
#endif
@ -840,8 +589,6 @@ int
g_rmdir (const gchar *filename)
{
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
@ -859,27 +606,6 @@ g_rmdir (const gchar *filename)
errno = save_errno;
return retval;
}
else
{
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
if (cp_filename == NULL)
{
errno = EINVAL;
return -1;
}
retval = rmdir (cp_filename);
save_errno = errno;
g_free (cp_filename);
errno = save_errno;
return retval;
}
#else
return rmdir (filename);
#endif
@ -906,8 +632,6 @@ g_fopen (const gchar *filename,
const gchar *mode)
{
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
wchar_t *wmode;
FILE *retval;
@ -936,27 +660,6 @@ g_fopen (const gchar *filename,
errno = save_errno;
return retval;
}
else
{
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
FILE *retval;
int save_errno;
if (cp_filename == NULL)
{
errno = EINVAL;
return NULL;
}
retval = fopen (cp_filename, mode);
save_errno = errno;
g_free (cp_filename);
errno = save_errno;
return retval;
}
#else
return fopen (filename, mode);
#endif
@ -985,8 +688,6 @@ g_freopen (const gchar *filename,
FILE *stream)
{
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
wchar_t *wmode;
FILE *retval;
@ -1015,27 +716,6 @@ g_freopen (const gchar *filename,
errno = save_errno;
return retval;
}
else
{
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
FILE *retval;
int save_errno;
if (cp_filename == NULL)
{
errno = EINVAL;
return NULL;
}
retval = freopen (cp_filename, mode, stream);
save_errno = errno;
g_free (cp_filename);
errno = save_errno;
return retval;
}
#else
return freopen (filename, mode, stream);
#endif

View File

@ -387,6 +387,9 @@ g_find_program_in_path (const gchar *program)
const gchar *path_copy;
gchar *filename = NULL, *appdir = NULL;
gchar *sysdir = NULL, *windir = NULL;
int n;
wchar_t wfilename[MAXPATHLEN], wsysdir[MAXPATHLEN],
wwindir[MAXPATHLEN];
#endif
size_t len;
size_t pathlen;
@ -427,12 +430,6 @@ g_find_program_in_path (const gchar *program)
path = "/bin:/usr/bin:.";
}
#else
if (G_WIN32_HAVE_WIDECHAR_API ())
{
int n;
wchar_t wfilename[MAXPATHLEN], wsysdir[MAXPATHLEN],
wwindir[MAXPATHLEN];
n = GetModuleFileNameW (NULL, wfilename, MAXPATHLEN);
if (n > 0 && n < MAXPATHLEN)
filename = g_utf16_to_utf8 (wfilename, -1, NULL, NULL, NULL);
@ -444,25 +441,6 @@ g_find_program_in_path (const gchar *program)
n = GetWindowsDirectoryW (wwindir, MAXPATHLEN);
if (n > 0 && n < MAXPATHLEN)
windir = g_utf16_to_utf8 (wwindir, -1, NULL, NULL, NULL);
}
else
{
int n;
gchar cpfilename[MAXPATHLEN], cpsysdir[MAXPATHLEN],
cpwindir[MAXPATHLEN];
n = GetModuleFileNameA (NULL, cpfilename, MAXPATHLEN);
if (n > 0 && n < MAXPATHLEN)
filename = g_locale_to_utf8 (cpfilename, -1, NULL, NULL, NULL);
n = GetSystemDirectoryA (cpsysdir, MAXPATHLEN);
if (n > 0 && n < MAXPATHLEN)
sysdir = g_locale_to_utf8 (cpsysdir, -1, NULL, NULL, NULL);
n = GetWindowsDirectoryA (cpwindir, MAXPATHLEN);
if (n > 0 && n < MAXPATHLEN)
windir = g_locale_to_utf8 (cpwindir, -1, NULL, NULL, NULL);
}
if (filename)
{
@ -939,9 +917,6 @@ g_get_current_dir (void)
#ifdef G_OS_WIN32
gchar *dir = NULL;
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t dummy[2], *wdir;
int len;
@ -952,20 +927,6 @@ g_get_current_dir (void)
dir = g_utf16_to_utf8 (wdir, -1, NULL, NULL, NULL);
g_free (wdir);
}
else
{
gchar dummy[2], *cpdir;
int len;
len = GetCurrentDirectoryA (2, dummy);
cpdir = g_new (gchar, len);
if (GetCurrentDirectoryA (len, cpdir) == len - 1)
dir = g_locale_to_utf8 (cpdir, -1, NULL, NULL, NULL);
g_free (cpdir);
}
if (dir == NULL)
dir = g_strdup ("\\");
@ -1048,6 +1009,8 @@ g_getenv (const gchar *variable)
GQuark quark;
gchar *value;
wchar_t dummy[2], *wname, *wvalue;
int len;
g_return_val_if_fail (variable != NULL, NULL);
g_return_val_if_fail (g_utf8_validate (variable, -1, NULL), NULL);
@ -1062,11 +1025,6 @@ g_getenv (const gchar *variable)
* contain references to other environment variables.)
*/
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t dummy[2], *wname, *wvalue;
int len;
wname = g_utf8_to_utf16 (variable, -1, NULL, NULL, NULL);
len = GetEnvironmentVariableW (wname, dummy, 2);
@ -1112,60 +1070,6 @@ g_getenv (const gchar *variable)
g_free (wname);
g_free (wvalue);
}
else
{
gchar dummy[3], *cpname, *cpvalue;
int len;
cpname = g_locale_from_utf8 (variable, -1, NULL, NULL, NULL);
g_return_val_if_fail (cpname != NULL, NULL);
len = GetEnvironmentVariableA (cpname, dummy, 2);
if (len == 0)
{
g_free (cpname);
return NULL;
}
else if (len == 1)
len = 2;
cpvalue = g_new (gchar, len);
if (GetEnvironmentVariableA (cpname, cpvalue, len) != len - 1)
{
g_free (cpname);
g_free (cpvalue);
return NULL;
}
if (strchr (cpvalue, '%') != NULL)
{
gchar *tem = cpvalue;
len = ExpandEnvironmentStringsA (cpvalue, dummy, 3);
if (len > 0)
{
cpvalue = g_new (gchar, len);
if (ExpandEnvironmentStringsA (tem, cpvalue, len) != len)
{
g_free (cpvalue);
cpvalue = tem;
}
else
g_free (tem);
}
}
value = g_locale_to_utf8 (cpvalue, -1, NULL, NULL, NULL);
g_free (cpname);
g_free (cpvalue);
}
quark = g_quark_from_string (value);
g_free (value);
@ -1250,6 +1154,8 @@ g_setenv (const gchar *variable,
#else /* G_OS_WIN32 */
gboolean retval;
wchar_t *wname, *wvalue, *wassignment;
gchar *tem;
g_return_val_if_fail (variable != NULL, FALSE);
g_return_val_if_fail (strchr (variable, '=') == NULL, FALSE);
@ -1273,12 +1179,10 @@ g_setenv (const gchar *variable,
* the putenv() first, then call SetEnvironmentValueW ourselves.
*/
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wname = g_utf8_to_utf16 (variable, -1, NULL, NULL, NULL);
wchar_t *wvalue = g_utf8_to_utf16 (value, -1, NULL, NULL, NULL);
gchar *tem = g_strconcat (variable, "=", value, NULL);
wchar_t *wassignment = g_utf8_to_utf16 (tem, -1, NULL, NULL, NULL);
wname = g_utf8_to_utf16 (variable, -1, NULL, NULL, NULL);
wvalue = g_utf8_to_utf16 (value, -1, NULL, NULL, NULL);
tem = g_strconcat (variable, "=", value, NULL);
wassignment = g_utf8_to_utf16 (tem, -1, NULL, NULL, NULL);
g_free (tem);
_wputenv (wassignment);
@ -1288,21 +1192,6 @@ g_setenv (const gchar *variable,
g_free (wname);
g_free (wvalue);
}
else
{
/* In the non-Unicode case (Win9x), just putenv() is good
* enough.
*/
gchar *tem = g_strconcat (variable, "=", value, NULL);
gchar *cpassignment = g_locale_from_utf8 (tem, -1, NULL, NULL, NULL);
g_free (tem);
retval = (putenv (cpassignment) == 0);
g_free (cpassignment);
}
return retval;
@ -1372,15 +1261,16 @@ g_unsetenv (const gchar *variable)
#else /* G_OS_WIN32 */
wchar_t *wname, *wassignment;
gchar *tem;
g_return_if_fail (variable != NULL);
g_return_if_fail (strchr (variable, '=') == NULL);
g_return_if_fail (g_utf8_validate (variable, -1, NULL));
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wname = g_utf8_to_utf16 (variable, -1, NULL, NULL, NULL);
gchar *tem = g_strconcat (variable, "=", NULL);
wchar_t *wassignment = g_utf8_to_utf16 (tem, -1, NULL, NULL, NULL);
wname = g_utf8_to_utf16 (variable, -1, NULL, NULL, NULL);
tem = g_strconcat (variable, "=", NULL);
wassignment = g_utf8_to_utf16 (tem, -1, NULL, NULL, NULL);
g_free (tem);
_wputenv (wassignment);
@ -1389,21 +1279,6 @@ g_unsetenv (const gchar *variable)
SetEnvironmentVariableW (wname, NULL);
g_free (wname);
}
else
{
/* In the non-Unicode case (Win9x), just putenv() is good
* enough.
*/
gchar *tem = g_strconcat (variable, "=", NULL);
gchar *cpassignment = g_locale_from_utf8 (tem, -1, NULL, NULL, NULL);
g_free (tem);
putenv (cpassignment);
g_free (cpassignment);
}
#endif /* G_OS_WIN32 */
}
@ -1448,10 +1323,7 @@ g_listenv (void)
return result;
#else
gchar **result, *eq;
gint len = 0, i, j;
if (G_WIN32_HAVE_WIDECHAR_API ())
{
gint len = 0, j;
wchar_t *p, *q;
p = (wchar_t *) GetEnvironmentStringsW ();
@ -1486,30 +1358,6 @@ g_listenv (void)
}
result[j] = NULL;
FreeEnvironmentStringsW (p);
}
else
{
len = g_strv_length (environ);
result = g_new0 (gchar *, len + 1);
j = 0;
for (i = 0; i < len; i++)
{
result[j] = g_locale_to_utf8 (environ[i], -1, NULL, NULL, NULL);
if (result[j] != NULL)
{
eq = strchr (result[j], '=');
if (eq && eq > result[j])
{
*eq = '\0';
j++;
}
else
g_free (result[j]);
}
}
result[j] = NULL;
}
return result;
#endif
@ -1555,19 +1403,10 @@ get_special_folder (int csidl)
hr = SHGetSpecialFolderLocation (NULL, csidl, &pidl);
if (hr == S_OK)
{
if (G_WIN32_HAVE_WIDECHAR_API ())
{
b = SHGetPathFromIDListW (pidl, path.wc);
if (b)
retval = g_utf16_to_utf8 (path.wc, -1, NULL, NULL, NULL);
}
else
{
b = SHGetPathFromIDListA (pidl, path.c);
if (b)
retval = g_locale_to_utf8 (path.c, -1, NULL, NULL, NULL);
}
CoTaskMemFree (pidl);
}
return retval;
@ -1788,8 +1627,6 @@ g_get_any_init_do (void)
#else /* !HAVE_PWD_H */
#ifdef G_OS_WIN32
if (G_WIN32_HAVE_WIDECHAR_API ())
{
guint len = UNLEN+1;
wchar_t buffer[UNLEN+1];
@ -1798,18 +1635,6 @@ g_get_any_init_do (void)
g_user_name = g_utf16_to_utf8 (buffer, -1, NULL, NULL, NULL);
g_real_name = g_strdup (g_user_name);
}
}
else
{
guint len = UNLEN+1;
char buffer[UNLEN+1];
if (GetUserNameA (buffer, (LPDWORD) &len))
{
g_user_name = g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
g_real_name = g_strdup (g_user_name);
}
}
#endif /* G_OS_WIN32 */
#endif /* !HAVE_PWD_H */
@ -2004,22 +1829,13 @@ g_get_prgname (void)
if (!beenhere)
{
gchar *utf8_buf = NULL;
wchar_t buf[MAX_PATH+1];
beenhere = TRUE;
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t buf[MAX_PATH+1];
if (GetModuleFileNameW (GetModuleHandle (NULL),
buf, G_N_ELEMENTS (buf)) > 0)
utf8_buf = g_utf16_to_utf8 (buf, -1, NULL, NULL, NULL);
}
else
{
gchar buf[MAX_PATH+1];
if (GetModuleFileNameA (GetModuleHandle (NULL),
buf, G_N_ELEMENTS (buf)) > 0)
utf8_buf = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
}
if (utf8_buf)
{
g_prgname = g_path_get_basename (utf8_buf);
@ -2314,23 +2130,14 @@ get_module_share_dir (gconstpointer address)
HMODULE hmodule;
gchar *filename = NULL;
gchar *p, *retval;
wchar_t wfilename[MAX_PATH];
hmodule = get_module_for_address (address);
if (hmodule == NULL)
return NULL;
if (G_WIN32_IS_NT_BASED ())
{
wchar_t wfilename[MAX_PATH];
if (GetModuleFileNameW (hmodule, wfilename, G_N_ELEMENTS (wfilename)))
filename = g_utf16_to_utf8 (wfilename, -1, NULL, NULL, NULL);
}
else
{
char cpfilename[MAX_PATH];
if (GetModuleFileNameA (hmodule, cpfilename, G_N_ELEMENTS (cpfilename)))
filename = g_locale_to_utf8 (cpfilename, -1, NULL, NULL, NULL);
}
if (filename == NULL)
return NULL;

View File

@ -1055,9 +1055,6 @@ gchar *
g_win32_error_message (gint error)
{
gchar *retval;
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *msg = NULL;
int nchars;
@ -1079,31 +1076,6 @@ g_win32_error_message (gint error)
}
else
retval = g_strdup ("");
}
else
{
gchar *msg = NULL;
int nbytes;
FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER
|FORMAT_MESSAGE_IGNORE_INSERTS
|FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error, 0,
(LPTSTR) &msg, 0, NULL);
if (msg != NULL)
{
nbytes = strlen (msg);
if (nbytes > 2 && msg[nbytes-1] == '\n' && msg[nbytes-2] == '\r')
msg[nbytes-2] = '\0';
retval = g_locale_to_utf8 (msg, -1, NULL, NULL, NULL);
LocalFree (msg);
}
else
retval = g_strdup ("");
}
return retval;
}
@ -1117,6 +1089,7 @@ get_package_directory_from_module (gchar *module_name)
gchar *fn;
gchar *p;
gchar *result;
wchar_t wc_fn[MAX_PATH];
G_LOCK (module_dirs);
@ -1132,43 +1105,21 @@ get_package_directory_from_module (gchar *module_name)
}
if (module_name)
{
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wc_module_name = g_utf8_to_utf16 (module_name, -1, NULL, NULL, NULL);
hmodule = GetModuleHandleW (wc_module_name);
g_free (wc_module_name);
}
else
{
char *cp_module_name = g_locale_from_utf8 (module_name, -1, NULL, NULL, NULL);
hmodule = GetModuleHandleA (cp_module_name);
g_free (cp_module_name);
}
if (!hmodule)
return NULL;
}
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t wc_fn[MAX_PATH];
if (!GetModuleFileNameW (hmodule, wc_fn, MAX_PATH))
{
G_UNLOCK (module_dirs);
return NULL;
}
fn = g_utf16_to_utf8 (wc_fn, -1, NULL, NULL, NULL);
}
else
{
gchar cp_fn[MAX_PATH];
if (!GetModuleFileNameA (hmodule, cp_fn, MAX_PATH))
{
G_UNLOCK (module_dirs);
return NULL;
}
fn = g_locale_to_utf8 (cp_fn, -1, NULL, NULL, NULL);
}
if ((p = strrchr (fn, G_DIR_SEPARATOR)) != NULL)
*p = '\0';
@ -1240,6 +1191,7 @@ g_win32_get_package_installation_directory (gchar *package,
G_LOCK_DEFINE_STATIC (package_dirs);
gchar *result = NULL;
gchar *key;
wchar_t *wc_key;
HKEY reg_key = NULL;
DWORD type;
DWORD nbytes;
@ -1262,9 +1214,8 @@ g_win32_get_package_installation_directory (gchar *package,
key = g_strconcat ("Software\\", package, NULL);
nbytes = 0;
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wc_key = g_utf8_to_utf16 (key, -1, NULL, NULL, NULL);
wc_key = g_utf8_to_utf16 (key, -1, NULL, NULL, NULL);
if (((RegOpenKeyExW (HKEY_CURRENT_USER, wc_key, 0,
KEY_QUERY_VALUE, &reg_key) == ERROR_SUCCESS
&& RegQueryValueExW (reg_key, L"InstallationDirectory", 0,
@ -1284,30 +1235,6 @@ g_win32_get_package_installation_directory (gchar *package,
g_free (wc_temp);
}
g_free (wc_key);
}
else
{
char *cp_key = g_locale_from_utf8 (key, -1, NULL, NULL, NULL);
if (((RegOpenKeyExA (HKEY_CURRENT_USER, cp_key, 0,
KEY_QUERY_VALUE, &reg_key) == ERROR_SUCCESS
&& RegQueryValueExA (reg_key, "InstallationDirectory", 0,
&type, NULL, &nbytes) == ERROR_SUCCESS)
||
(RegOpenKeyExA (HKEY_LOCAL_MACHINE, cp_key, 0,
KEY_QUERY_VALUE, &reg_key) == ERROR_SUCCESS
&& RegQueryValueExA (reg_key, "InstallationDirectory", 0,
&type, NULL, &nbytes) == ERROR_SUCCESS))
&& type == REG_SZ)
{
char *cp_temp = g_malloc (nbytes + 1);
RegQueryValueExA (reg_key, "InstallationDirectory", 0,
&type, cp_temp, &nbytes);
cp_temp[nbytes] = '\0';
result = g_locale_to_utf8 (cp_temp, -1, NULL, NULL, NULL);
g_free (cp_temp);
}
g_free (cp_key);
}
if (reg_key != NULL)
RegCloseKey (reg_key);
@ -1425,10 +1352,10 @@ g_win32_windows_version_init (void)
if (!beenhere)
{
beenhere = TRUE;
if (getenv ("G_WIN32_PRETEND_WIN9X"))
windows_version = 0x80000004;
else
windows_version = GetVersion ();
if (windows_version & 0x80000000)
g_error ("This version of GLib requires NT-based Windows.");
}
}
@ -1444,17 +1371,13 @@ _g_win32_thread_init (void)
* Returns version information for the Windows operating system the
* code is running on. See MSDN documentation for the GetVersion()
* function. To summarize, the most significant bit is one on Win9x,
* and zero on NT-based systems. The least significant byte is 4 on
* Windows NT 4, 5 on Windows XP. Software that needs really detailled
* version and feature information should use Win32 API like
* and zero on NT-based systems. Since version 2.14, GLib works only
* on NT-based systems, so checking whether your are running on Win9x
* in your own software is moot. The least significant byte is 4 on
* Windows NT 4, and 5 on Windows XP. Software that needs really
* detailled version and feature information should use Win32 API like
* GetVersionEx() and VerifyVersionInfo().
*
* If there is an environment variable <envar>G_WIN32_PRETEND_WIN9X</envar>
* defined (with any value), this function always returns a version
* code for Windows 9x. This is mainly an internal debugging aid for
* GTK+ and GLib developers, to be able to check the code paths for
* Windows 9x.
*
* Returns: The version information.
*
* Since: 2.6
@ -1501,7 +1424,7 @@ g_win32_locale_filename_from_utf8 (const gchar *utf8filename)
{
gchar *retval = g_locale_from_utf8 (utf8filename, -1, NULL, NULL, NULL);
if (retval == NULL && G_WIN32_HAVE_WIDECHAR_API ())
if (retval == NULL)
{
/* Conversion failed, so convert to wide chars, check if there
* is a 8.3 version, and use that.

View File

@ -93,8 +93,9 @@ guint g_win32_get_windows_version (void);
gchar* g_win32_locale_filename_from_utf8 (const gchar *utf8filename);
#define G_WIN32_IS_NT_BASED() (g_win32_get_windows_version () < 0x80000000)
#define G_WIN32_HAVE_WIDECHAR_API() (G_WIN32_IS_NT_BASED ())
/* As of GLib 2.14 we only support NT-based Windows */
#define G_WIN32_IS_NT_BASED() TRUE
#define G_WIN32_HAVE_WIDECHAR_API() TRUE
G_END_DECLS

View File

@ -1,3 +1,13 @@
2006-08-29 Tor Lillqvist <tml@novell.com>
Remove support for Windows 9x/ME. GTK+ hasn't worked on Win9x
since 2.6. It's pointless to keep the Win9x code in here as it
isn't being maintained anyway. If somebody is interested, it is in
older GLib versions, and in CVS.
* gmodule-win32.c (_g_module_open): Remove the Win9x branch of if
statement.
2006-08-15 Matthias Clasen <mclasen@redhat.com>
* === Released 2.12.2 ===

View File

@ -56,26 +56,17 @@ _g_module_open (const gchar *file_name,
gboolean bind_local)
{
HINSTANCE handle;
wchar_t *wfilename;
#ifdef G_WITH_CYGWIN
gchar tmp[MAX_PATH];
cygwin_conv_to_win32_path(file_name, tmp);
file_name = tmp;
#endif
if (G_WIN32_HAVE_WIDECHAR_API ())
{
wchar_t *wfilename = g_utf8_to_utf16 (file_name, -1, NULL, NULL, NULL);
wfilename = g_utf8_to_utf16 (file_name, -1, NULL, NULL, NULL);
handle = LoadLibraryW (wfilename);
g_free (wfilename);
}
else
{
gchar *cp_filename = g_locale_from_utf8 (file_name, -1, NULL, NULL, NULL);
handle = LoadLibraryA (cp_filename);
g_free (cp_filename);
}
if (!handle)
set_error ();