+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.
#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>
struct _GDir
{
- union {
- DIR *dirp;
#ifdef G_OS_WIN32
- _WDIR *wdirp;
+ _WDIR *wdirp;
+#else
+ DIR *dirp;
#endif
- } u;
#ifdef G_OS_WIN32
gchar utf8_buf[FILENAME_MAX*4];
#endif
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);
-
- if (wpath == NULL)
- return NULL;
-
- dir = g_new (GDir, 1);
-
- dir->u.wdirp = _wopendir (wpath);
- g_free (wpath);
-
- if (dir->u.wdirp)
- return dir;
- }
- else
- {
- gchar *cp_path = g_locale_from_utf8 (path, -1, NULL, NULL, error);
+ wpath = g_utf8_to_utf16 (path, -1, NULL, NULL, error);
- if (cp_path == NULL)
- return NULL;
-
- dir = g_new (GDir, 1);
+ if (wpath == NULL)
+ return NULL;
- dir->u.dirp = opendir (cp_path);
+ dir = g_new (GDir, 1);
- g_free (cp_path);
+ dir->wdirp = _wopendir (wpath);
+ g_free (wpath);
- if (dir->u.dirp)
- return dir;
- }
+ if (dir->wdirp)
+ return dir;
/* error case */
#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 */
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 ())
+ while (1)
{
- gchar *utf8_name;
- struct _wdirent *wentry;
+ wentry = _wreaddir (dir->wdirp);
+ while (wentry
+ && (0 == wcscmp (wentry->d_name, L".") ||
+ 0 == wcscmp (wentry->d_name, L"..")))
+ wentry = _wreaddir (dir->wdirp);
- while (1)
- {
- wentry = _wreaddir (dir->u.wdirp);
- while (wentry
- && (0 == wcscmp (wentry->d_name, L".") ||
- 0 == wcscmp (wentry->d_name, L"..")))
- wentry = _wreaddir (dir->u.wdirp);
-
- if (wentry == NULL)
- return NULL;
-
- utf8_name = g_utf16_to_utf8 (wentry->d_name, -1, NULL, NULL, NULL);
-
- if (utf8_name == NULL)
- continue; /* Huh, impossible? Skip it anyway */
-
- strcpy (dir->utf8_buf, utf8_name);
- g_free (utf8_name);
-
- 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;
- }
- }
+ if (wentry == NULL)
+ return NULL;
+
+ utf8_name = g_utf16_to_utf8 (wentry->d_name, -1, NULL, NULL, NULL);
+
+ if (utf8_name == NULL)
+ continue; /* Huh, impossible? Skip it anyway */
+
+ 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;
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);
}
/**
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);
}
# define FILE_ATTRIBUTE_DEVICE 64
# endif
int attributes;
+ wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
- if (G_WIN32_HAVE_WIDECHAR_API ())
- {
- wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
-
- if (wfilename == NULL)
- return FALSE;
-
- attributes = GetFileAttributesW (wfilename);
+ if (wfilename == NULL)
+ return FALSE;
- g_free (wfilename);
- }
- else
- {
- gchar *cpfilename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
+ attributes = GetFileAttributesW (wfilename);
- if (cpfilename == NULL)
- return FALSE;
-
- attributes = GetFileAttributesA (cpfilename);
-
- g_free (cpfilename);
- }
+ g_free (wfilename);
if (attributes == INVALID_FILE_ATTRIBUTES)
return FALSE;
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;
g_assert (__argc >= ARG_COUNT);
- if (G_WIN32_HAVE_WIDECHAR_API ())
- {
- /* Fetch the wide-char argument vector */
- __wgetmainargs (&argc, &wargv, &wenvp, 0, &si);
-
- /* We still have the system codepage args in __argv. We can look
- * at the first args in which gspawn-win32.c passes us flags and
- * fd numbers in __argv, as we know those are just ASCII anyway.
- */
- g_assert (argc == __argc);
- }
+ /* Fetch the wide-char argument vector */
+ __wgetmainargs (&argc, &wargv, &wenvp, 0, &si);
+
+ /* We still have the system codepage args in __argv. We can look
+ * at the first args in which gspawn-win32.c passes us flags and
+ * 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.
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
/* 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);
+ 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);
- }
+ if (__argv[ARG_USE_PATH][0] == 'y')
+ handle = _wspawnvp (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);
- }
+ handle = _wspawnv (mode, wargv[ARG_PROGRAM], (const wchar_t **) new_wargv);
saved_errno = errno;
ARG_COUNT = ARG_PROGRAM
};
+#ifndef GSPAWN_HELPER
+
+#define HELPER_PROCESS "gspawn-win32-helper"
+
static gchar *
protect_argv_string (const gchar *string)
{
return argc;
}
-#ifndef GSPAWN_HELPER
-
-#define HELPER_PROCESS "gspawn-win32-helper"
-
GQuark
g_spawn_error_quark (void)
{
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,
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)
- {
- 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_wcharv (new_argv, &wargv, &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 (wargv0);
-
- return FALSE;
- }
-
- if (!utf8_charv_to_wcharv (envp, &wenvp, 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 (wargv0);
- g_strfreev ((gchar **) wargv);
-
- return FALSE;
- }
-
- if (child_setup)
- (* child_setup) (user_data);
-
- if (flags & G_SPAWN_SEARCH_PATH)
- if (wenvp != NULL)
- rc = _wspawnvpe (mode, wargv0, (const wchar_t **) wargv, (const wchar_t **) wenvp);
- else
- rc = _wspawnvp (mode, wargv0, (const wchar_t **) wargv);
- else
- if (wenvp != NULL)
- rc = _wspawnve (mode, wargv0, (const wchar_t **) wargv, (const wchar_t **) wenvp);
- else
- rc = _wspawnv (mode, wargv0, (const wchar_t **) wargv);
+ wargv0 = g_utf8_to_utf16 (argv[0], -1, NULL, NULL, &conv_error);
+ if (wargv0 == NULL)
+ {
+ g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
+ _("Invalid program name: %s"),
+ conv_error->message);
+ g_error_free (conv_error);
- g_free (wargv0);
- g_strfreev ((gchar **) wargv);
- g_strfreev ((gchar **) wenvp);
+ return FALSE;
}
- else
+
+ if (!utf8_charv_to_wcharv (new_argv, &wargv, &conv_error_index, &conv_error))
{
- 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;
- }
+ 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 (wargv0);
- 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;
+ }
- return FALSE;
- }
+ if (!utf8_charv_to_wcharv (envp, &wenvp, 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 (wargv0);
+ g_strfreev ((gchar **) wargv);
- 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;
+ }
- return FALSE;
- }
+ if (child_setup)
+ (* child_setup) (user_data);
- if (child_setup)
- (* child_setup) (user_data);
+ if (flags & G_SPAWN_SEARCH_PATH)
+ if (wenvp != NULL)
+ rc = _wspawnvpe (mode, wargv0, (const wchar_t **) wargv, (const wchar_t **) wenvp);
+ else
+ rc = _wspawnvp (mode, wargv0, (const wchar_t **) wargv);
+ else
+ if (wenvp != NULL)
+ rc = _wspawnve (mode, wargv0, (const wchar_t **) wargv, (const wchar_t **) wenvp);
+ else
+ rc = _wspawnv (mode, wargv0, (const wchar_t **) wargv);
- 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);
- }
+ g_free (wargv0);
+ g_strfreev ((gchar **) wargv);
+ g_strfreev ((gchar **) wenvp);
saved_errno = errno;
gint conv_error_index;
gchar *helper_process;
CONSOLE_CURSOR_INFO cursor_info;
+ wchar_t *whelper, **wargv, **wenvp;
SETUP_DEBUG();
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;
-
- if (!utf8_charv_to_wcharv (new_argv, &wargv, &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);
- g_free (whelper);
-
- return FALSE;
- }
-
- if (!utf8_charv_to_wcharv (envp, &wenvp, 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_free (whelper);
- g_strfreev ((gchar **) wargv);
-
- return FALSE;
- }
-
- if (child_setup)
- (* child_setup) (user_data);
+ whelper = g_utf8_to_utf16 (helper_process, -1, NULL, NULL, NULL);
- if (wenvp != NULL)
- /* Let's hope envp hasn't mucked with PATH so that
- * gspawn-win32-helper.exe isn't found.
- */
- rc = _wspawnvpe (P_NOWAIT, whelper, (const wchar_t **) wargv, (const wchar_t **) wenvp);
+ if (!utf8_charv_to_wcharv (new_argv, &wargv, &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
- rc = _wspawnvp (P_NOWAIT, whelper, (const wchar_t **) wargv);
+ 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);
+ g_free (whelper);
- saved_errno = errno;
+ return FALSE;
+ }
+ if (!utf8_charv_to_wcharv (envp, &wenvp, 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_free (whelper);
g_strfreev ((gchar **) wargv);
- g_strfreev ((gchar **) wenvp);
+
+ return FALSE;
}
- 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 (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);
+ if (wenvp != NULL)
+ /* Let's hope envp hasn't mucked with PATH so that
+ * gspawn-win32-helper.exe isn't found.
+ */
+ rc = _wspawnvpe (P_NOWAIT, whelper, (const wchar_t **) wargv, (const wchar_t **) wenvp);
+ else
+ rc = _wspawnvp (P_NOWAIT, whelper, (const wchar_t **) wargv);
- saved_errno = errno;
+ saved_errno = errno;
- g_strfreev (cpargv);
- g_strfreev (cpenvp);
- }
+ g_free (whelper);
+ g_strfreev ((gchar **) wargv);
+ g_strfreev ((gchar **) wenvp);
/* Close the other process's ends of the pipes in this process,
* otherwise the reader will never get EOF.
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;
+
+ if (wfilename == NULL)
{
- wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
- int retval;
- int save_errno;
-
- if (wfilename == NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- retval = _waccess (wfilename, mode);
- save_errno = errno;
-
- g_free (wfilename);
-
- errno = save_errno;
- return retval;
+ errno = EINVAL;
+ return -1;
}
- 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;
+ retval = _waccess (wfilename, mode);
+ save_errno = errno;
- g_free (cp_filename);
+ g_free (wfilename);
- errno = save_errno;
- return retval;
- }
+ errno = save_errno;
+ return retval;
#else
return access (filename, mode);
#endif
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;
+
+ if (wfilename == NULL)
{
- wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
- int retval;
- int save_errno;
-
- if (wfilename == NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- retval = _wchmod (wfilename, mode);
- save_errno = errno;
-
- g_free (wfilename);
-
- errno = save_errno;
- return retval;
+ errno = EINVAL;
+ return -1;
}
- 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;
+ retval = _wchmod (wfilename, mode);
+ save_errno = errno;
- g_free (cp_filename);
+ g_free (wfilename);
- errno = save_errno;
- return retval;
- }
+ errno = save_errno;
+ return retval;
#else
return chmod (filename, mode);
#endif
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;
+
+ if (wfilename == NULL)
{
- wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
- int retval;
- int save_errno;
-
- if (wfilename == NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- retval = _wopen (wfilename, flags, mode);
- save_errno = errno;
-
- g_free (wfilename);
-
- errno = save_errno;
- return retval;
+ errno = EINVAL;
+ return -1;
}
- 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;
+ retval = _wopen (wfilename, flags, mode);
+ save_errno = errno;
- g_free (cp_filename);
+ g_free (wfilename);
- errno = save_errno;
- return retval;
- }
+ errno = save_errno;
+ return retval;
#else
return open (filename, flags, mode);
#endif
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;
+
+ if (wfilename == NULL)
{
- wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
- int retval;
- int save_errno;
-
- if (wfilename == NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- retval = _wcreat (wfilename, mode);
- save_errno = errno;
-
- g_free (wfilename);
-
- errno = save_errno;
- return retval;
+ errno = EINVAL;
+ return -1;
}
- 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;
+ retval = _wcreat (wfilename, mode);
+ save_errno = errno;
- g_free (cp_filename);
+ g_free (wfilename);
- errno = save_errno;
- return retval;
- }
+ errno = save_errno;
+ return retval;
#else
return creat (filename, mode);
#endif
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;
- int save_errno;
-
- if (woldfilename == NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- wnewfilename = g_utf8_to_utf16 (newfilename, -1, NULL, NULL, NULL);
+ wchar_t *woldfilename = g_utf8_to_utf16 (oldfilename, -1, NULL, NULL, NULL);
+ wchar_t *wnewfilename;
+ int retval;
+ int save_errno;
- if (wnewfilename == NULL)
- {
- g_free (woldfilename);
- errno = EINVAL;
- return -1;
- }
+ if (woldfilename == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
- if (MoveFileExW (woldfilename, wnewfilename, MOVEFILE_REPLACE_EXISTING))
- retval = 0;
- else
- {
- retval = -1;
- switch (GetLastError ())
- {
-#define CASE(a,b) case ERROR_##a: save_errno = b; break
- CASE (FILE_NOT_FOUND, ENOENT);
- CASE (PATH_NOT_FOUND, ENOENT);
- CASE (ACCESS_DENIED, EACCES);
- CASE (NOT_SAME_DEVICE, EXDEV);
- CASE (LOCK_VIOLATION, EACCES);
- CASE (SHARING_VIOLATION, EACCES);
- CASE (FILE_EXISTS, EEXIST);
- CASE (ALREADY_EXISTS, EEXIST);
-#undef CASE
- default: save_errno = EIO;
- }
- }
+ wnewfilename = g_utf8_to_utf16 (newfilename, -1, NULL, NULL, NULL);
+ if (wnewfilename == NULL)
+ {
g_free (woldfilename);
- g_free (wnewfilename);
-
- errno = save_errno;
- return retval;
+ errno = EINVAL;
+ return -1;
}
+
+ if (MoveFileExW (woldfilename, wnewfilename, MOVEFILE_REPLACE_EXISTING))
+ retval = 0;
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)
+ retval = -1;
+ switch (GetLastError ())
{
- g_free (cp_oldfilename);
- errno = EINVAL;
- return -1;
+#define CASE(a,b) case ERROR_##a: save_errno = b; break
+ CASE (FILE_NOT_FOUND, ENOENT);
+ CASE (PATH_NOT_FOUND, ENOENT);
+ CASE (ACCESS_DENIED, EACCES);
+ CASE (NOT_SAME_DEVICE, EXDEV);
+ CASE (LOCK_VIOLATION, EACCES);
+ CASE (SHARING_VIOLATION, EACCES);
+ CASE (FILE_EXISTS, EEXIST);
+ CASE (ALREADY_EXISTS, EEXIST);
+#undef CASE
+ default: save_errno = EIO;
}
-
- retval = rename (cp_oldfilename, cp_newfilename);
- save_errno = errno;
-
- g_free (cp_oldfilename);
- g_free (cp_newfilename);
-
- errno = save_errno;
- return retval;
}
+
+ g_free (woldfilename);
+ g_free (wnewfilename);
+
+ errno = save_errno;
+ return retval;
#else
return rename (oldfilename, newfilename);
#endif
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;
-
- if (wfilename == NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- retval = _wmkdir (wfilename);
- save_errno = errno;
+ wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
+ int retval;
+ int save_errno;
- g_free (wfilename);
-
- errno = save_errno;
- return retval;
- }
- else
+ if (wfilename == NULL)
{
- 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;
+ errno = EINVAL;
+ return -1;
+ }
- g_free (cp_filename);
+ retval = _wmkdir (wfilename);
+ save_errno = errno;
- errno = save_errno;
- return retval;
- }
+ g_free (wfilename);
+
+ errno = save_errno;
+ return retval;
#else
return mkdir (filename, mode);
#endif
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;
-
- if (wpath == NULL)
- {
- errno = EINVAL;
- return -1;
- }
+ wchar_t *wpath = g_utf8_to_utf16 (path, -1, NULL, NULL, NULL);
+ int retval;
+ int save_errno;
- retval = _wchdir (wpath);
- save_errno = errno;
-
- g_free (wpath);
-
- errno = save_errno;
- return retval;
- }
- else
+ if (wpath == NULL)
{
- 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;
+ errno = EINVAL;
+ return -1;
+ }
- g_free (cp_path);
+ retval = _wchdir (wpath);
+ save_errno = errno;
- errno = save_errno;
- return retval;
- }
+ g_free (wpath);
+
+ errno = save_errno;
+ return retval;
#else
return chdir (path);
#endif
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;
- int len;
-
- if (wfilename == NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- len = wcslen (wfilename);
- while (len > 0 && G_IS_DIR_SEPARATOR (wfilename[len-1]))
- len--;
- if (len > 0 &&
- (!g_path_is_absolute (filename) || len > g_path_skip_root (filename) - filename))
- wfilename[len] = '\0';
-
- retval = _wstat (wfilename, (struct _stat *) buf);
- save_errno = errno;
-
- g_free (wfilename);
+ wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
+ int retval;
+ int save_errno;
+ int len;
- errno = save_errno;
- return retval;
- }
- else
+ if (wfilename == NULL)
{
- gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
- int retval;
- int save_errno;
- int len;
+ errno = EINVAL;
+ return -1;
+ }
- if (cp_filename == NULL)
- {
- errno = EINVAL;
- return -1;
- }
+ len = wcslen (wfilename);
+ while (len > 0 && G_IS_DIR_SEPARATOR (wfilename[len-1]))
+ len--;
+ if (len > 0 &&
+ (!g_path_is_absolute (filename) || len > g_path_skip_root (filename) - filename))
+ wfilename[len] = '\0';
- 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;
+ retval = _wstat (wfilename, (struct _stat *) buf);
+ save_errno = errno;
- g_free (cp_filename);
+ g_free (wfilename);
- errno = save_errno;
- return retval;
- }
+ errno = save_errno;
+ return retval;
#else
return stat (filename, buf);
#endif
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;
-
- if (wfilename == NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- retval = _wunlink (wfilename);
- save_errno = errno;
+ wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
+ int retval;
+ int save_errno;
- g_free (wfilename);
-
- errno = save_errno;
- return retval;
- }
- else
+ if (wfilename == NULL)
{
- 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;
- }
+ errno = EINVAL;
+ return -1;
+ }
- retval = unlink (cp_filename);
- save_errno = errno;
+ retval = _wunlink (wfilename);
+ save_errno = errno;
- g_free (cp_filename);
+ g_free (wfilename);
- errno = save_errno;
- return retval;
- }
+ errno = save_errno;
+ return retval;
#else
return unlink (filename);
#endif
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;
+ wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
+ int retval;
+ int save_errno;
- if (wfilename == NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- retval = _wremove (wfilename);
- if (retval == -1)
- retval = _wrmdir (wfilename);
- save_errno = errno;
-
- g_free (wfilename);
-
- errno = save_errno;
- return retval;
- }
- else
+ if (wfilename == NULL)
{
- 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;
- }
+ errno = EINVAL;
+ return -1;
+ }
- retval = remove (cp_filename);
- if (retval == -1)
- retval = rmdir (cp_filename);
- save_errno = errno;
+ retval = _wremove (wfilename);
+ if (retval == -1)
+ retval = _wrmdir (wfilename);
+ save_errno = errno;
- g_free (cp_filename);
+ g_free (wfilename);
- errno = save_errno;
- return retval;
- }
+ errno = save_errno;
+ return retval;
#else
return remove (filename);
#endif
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;
+ wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
+ int retval;
+ int save_errno;
- if (wfilename == NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- retval = _wrmdir (wfilename);
- save_errno = errno;
-
- g_free (wfilename);
-
- errno = save_errno;
- return retval;
- }
- else
+ if (wfilename == NULL)
{
- 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;
+ errno = EINVAL;
+ return -1;
+ }
+
+ retval = _wrmdir (wfilename);
+ save_errno = errno;
- g_free (cp_filename);
+ g_free (wfilename);
- errno = save_errno;
- return retval;
- }
+ errno = save_errno;
+ return retval;
#else
return rmdir (filename);
#endif
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;
- int save_errno;
-
- if (wfilename == NULL)
- {
- errno = EINVAL;
- return NULL;
- }
+ wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
+ wchar_t *wmode;
+ FILE *retval;
+ int save_errno;
- wmode = g_utf8_to_utf16 (mode, -1, NULL, NULL, NULL);
+ if (wfilename == NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
- if (wmode == NULL)
- {
- g_free (wfilename);
- errno = EINVAL;
- return NULL;
- }
-
- retval = _wfopen (wfilename, wmode);
- save_errno = errno;
+ wmode = g_utf8_to_utf16 (mode, -1, NULL, NULL, NULL);
+ if (wmode == NULL)
+ {
g_free (wfilename);
- g_free (wmode);
-
- errno = save_errno;
- return retval;
+ errno = EINVAL;
+ return NULL;
}
- 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;
+ retval = _wfopen (wfilename, wmode);
+ save_errno = errno;
- g_free (cp_filename);
+ g_free (wfilename);
+ g_free (wmode);
- errno = save_errno;
- return retval;
- }
+ errno = save_errno;
+ return retval;
#else
return fopen (filename, mode);
#endif
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;
- int save_errno;
-
- if (wfilename == NULL)
- {
- errno = EINVAL;
- return NULL;
- }
-
- wmode = g_utf8_to_utf16 (mode, -1, NULL, NULL, NULL);
+ wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
+ wchar_t *wmode;
+ FILE *retval;
+ int save_errno;
- if (wmode == NULL)
- {
- g_free (wfilename);
- errno = EINVAL;
- return NULL;
- }
-
- retval = _wfreopen (wfilename, wmode, stream);
- save_errno = errno;
+ if (wfilename == NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ wmode = g_utf8_to_utf16 (mode, -1, NULL, NULL, NULL);
+ if (wmode == NULL)
+ {
g_free (wfilename);
- g_free (wmode);
-
- errno = save_errno;
- return retval;
+ errno = EINVAL;
+ return NULL;
}
- else
- {
- gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
- FILE *retval;
- int save_errno;
+
+ retval = _wfreopen (wfilename, wmode, stream);
+ save_errno = errno;
- if (cp_filename == NULL)
- {
- errno = EINVAL;
- return NULL;
- }
-
- retval = freopen (cp_filename, mode, stream);
- save_errno = errno;
+ g_free (wfilename);
+ g_free (wmode);
- g_free (cp_filename);
-
- errno = save_errno;
- return retval;
- }
+ errno = save_errno;
+ return retval;
#else
return freopen (filename, mode, stream);
#endif
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;
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);
-
- n = GetSystemDirectoryW (wsysdir, MAXPATHLEN);
- if (n > 0 && n < MAXPATHLEN)
- sysdir = g_utf16_to_utf8 (wsysdir, -1, NULL, NULL, NULL);
-
- 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);
- }
+ n = GetModuleFileNameW (NULL, wfilename, MAXPATHLEN);
+ if (n > 0 && n < MAXPATHLEN)
+ filename = g_utf16_to_utf8 (wfilename, -1, NULL, NULL, NULL);
+
+ n = GetSystemDirectoryW (wsysdir, MAXPATHLEN);
+ if (n > 0 && n < MAXPATHLEN)
+ sysdir = g_utf16_to_utf8 (wsysdir, -1, NULL, NULL, NULL);
+
+ n = GetWindowsDirectoryW (wwindir, MAXPATHLEN);
+ if (n > 0 && n < MAXPATHLEN)
+ windir = g_utf16_to_utf8 (wwindir, -1, NULL, NULL, NULL);
if (filename)
{
#ifdef G_OS_WIN32
gchar *dir = NULL;
+ wchar_t dummy[2], *wdir;
+ int len;
- if (G_WIN32_HAVE_WIDECHAR_API ())
- {
- wchar_t dummy[2], *wdir;
- int len;
-
- len = GetCurrentDirectoryW (2, dummy);
- wdir = g_new (wchar_t, len);
-
- if (GetCurrentDirectoryW (len, wdir) == len - 1)
- 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);
+ len = GetCurrentDirectoryW (2, dummy);
+ wdir = g_new (wchar_t, len);
- g_free (cpdir);
- }
+ if (GetCurrentDirectoryW (len, wdir) == len - 1)
+ dir = g_utf16_to_utf8 (wdir, -1, NULL, NULL, NULL);
+
+ g_free (wdir);
if (dir == NULL)
dir = g_strdup ("\\");
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);
* 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);
-
- if (len == 0)
- {
- g_free (wname);
- return NULL;
- }
- else if (len == 1)
- len = 2;
-
- wvalue = g_new (wchar_t, len);
-
- if (GetEnvironmentVariableW (wname, wvalue, len) != len - 1)
- {
- g_free (wname);
- g_free (wvalue);
- return NULL;
- }
-
- if (wcschr (wvalue, L'%') != NULL)
- {
- wchar_t *tem = wvalue;
+ wname = g_utf8_to_utf16 (variable, -1, NULL, NULL, NULL);
- len = ExpandEnvironmentStringsW (wvalue, dummy, 2);
-
- if (len > 0)
- {
- wvalue = g_new (wchar_t, len);
+ len = GetEnvironmentVariableW (wname, dummy, 2);
- if (ExpandEnvironmentStringsW (tem, wvalue, len) != len)
- {
- g_free (wvalue);
- wvalue = tem;
- }
- else
- g_free (tem);
- }
- }
+ if (len == 0)
+ {
+ g_free (wname);
+ return NULL;
+ }
+ else if (len == 1)
+ len = 2;
- value = g_utf16_to_utf8 (wvalue, -1, NULL, NULL, NULL);
+ wvalue = g_new (wchar_t, len);
+ if (GetEnvironmentVariableW (wname, wvalue, len) != len - 1)
+ {
g_free (wname);
g_free (wvalue);
+ return NULL;
}
- 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 (wcschr (wvalue, L'%') != NULL)
+ {
+ wchar_t *tem = wvalue;
- if (GetEnvironmentVariableA (cpname, cpvalue, len) != len - 1)
- {
- g_free (cpname);
- g_free (cpvalue);
- return NULL;
- }
+ len = ExpandEnvironmentStringsW (wvalue, dummy, 2);
- if (strchr (cpvalue, '%') != NULL)
+ if (len > 0)
{
- gchar *tem = cpvalue;
-
- len = ExpandEnvironmentStringsA (cpvalue, dummy, 3);
+ wvalue = g_new (wchar_t, len);
- if (len > 0)
+ if (ExpandEnvironmentStringsW (tem, wvalue, len) != len)
{
- cpvalue = g_new (gchar, len);
-
- if (ExpandEnvironmentStringsA (tem, cpvalue, len) != len)
- {
- g_free (cpvalue);
- cpvalue = tem;
- }
- else
- g_free (tem);
+ g_free (wvalue);
+ wvalue = tem;
}
+ else
+ g_free (tem);
}
+ }
- value = g_locale_to_utf8 (cpvalue, -1, NULL, NULL, NULL);
+ value = g_utf16_to_utf8 (wvalue, -1, NULL, NULL, NULL);
- g_free (cpname);
- g_free (cpvalue);
- }
+ g_free (wname);
+ g_free (wvalue);
quark = g_quark_from_string (value);
g_free (value);
#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);
* 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);
-
- g_free (tem);
- _wputenv (wassignment);
- g_free (wassignment);
-
- retval = (SetEnvironmentVariableW (wname, wvalue) != 0);
-
- 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);
+ 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);
+ g_free (wassignment);
- g_free (tem);
-
- retval = (putenv (cpassignment) == 0);
+ retval = (SetEnvironmentVariableW (wname, wvalue) != 0);
- g_free (cpassignment);
- }
+ g_free (wname);
+ g_free (wvalue);
return retval;
#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);
-
- g_free (tem);
- _wputenv (wassignment);
- g_free (wassignment);
-
- 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);
+ 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);
+ g_free (wassignment);
- g_free (tem);
-
- putenv (cpassignment);
+ SetEnvironmentVariableW (wname, NULL);
- g_free (cpassignment);
- }
+ g_free (wname);
#endif /* G_OS_WIN32 */
}
return result;
#else
gchar **result, *eq;
- gint len = 0, i, j;
+ gint len = 0, j;
+ wchar_t *p, *q;
- if (G_WIN32_HAVE_WIDECHAR_API ())
+ p = (wchar_t *) GetEnvironmentStringsW ();
+ if (p != NULL)
{
- wchar_t *p, *q;
-
- p = (wchar_t *) GetEnvironmentStringsW ();
- if (p != NULL)
- {
- q = p;
- while (*q)
- {
- q += wcslen (q) + 1;
- len++;
- }
- }
- result = g_new0 (gchar *, len + 1);
-
- j = 0;
q = p;
while (*q)
{
- result[j] = g_utf16_to_utf8 (q, -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]);
- }
q += wcslen (q) + 1;
+ len++;
}
- result[j] = NULL;
- FreeEnvironmentStringsW (p);
}
- else
+ result = g_new0 (gchar *, len + 1);
+
+ j = 0;
+ q = p;
+ while (*q)
{
- len = g_strv_length (environ);
- result = g_new0 (gchar *, len + 1);
-
- j = 0;
- for (i = 0; i < len; i++)
+ result[j] = g_utf16_to_utf8 (q, -1, NULL, NULL, NULL);
+ if (result[j] != NULL)
{
- 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 = strchr (result[j], '=');
- if (eq && eq > result[j])
- {
- *eq = '\0';
- j++;
- }
- else
- g_free (result[j]);
+ *eq = '\0';
+ j++;
}
+ else
+ g_free (result[j]);
}
- result[j] = NULL;
+ q += wcslen (q) + 1;
}
+ result[j] = NULL;
+ FreeEnvironmentStringsW (p);
return result;
#endif
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);
- }
+ b = SHGetPathFromIDListW (pidl, path.wc);
+ if (b)
+ retval = g_utf16_to_utf8 (path.wc, -1, NULL, NULL, NULL);
CoTaskMemFree (pidl);
}
return retval;
#else /* !HAVE_PWD_H */
#ifdef G_OS_WIN32
- if (G_WIN32_HAVE_WIDECHAR_API ())
- {
- guint len = UNLEN+1;
- wchar_t buffer[UNLEN+1];
-
- if (GetUserNameW (buffer, (LPDWORD) &len))
- {
- 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;
+ wchar_t buffer[UNLEN+1];
+
+ if (GetUserNameW (buffer, (LPDWORD) &len))
{
- 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);
- }
+ g_user_name = g_utf16_to_utf8 (buffer, -1, NULL, NULL, NULL);
+ g_real_name = g_strdup (g_user_name);
}
#endif /* G_OS_WIN32 */
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 (GetModuleFileNameW (GetModuleHandle (NULL),
+ buf, G_N_ELEMENTS (buf)) > 0)
+ utf8_buf = g_utf16_to_utf8 (buf, -1, NULL, NULL, NULL);
+
if (utf8_buf)
{
g_prgname = g_path_get_basename (utf8_buf);
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 (GetModuleFileNameW (hmodule, wfilename, G_N_ELEMENTS (wfilename)))
+ filename = g_utf16_to_utf8 (wfilename, -1, NULL, NULL, NULL);
if (filename == NULL)
return NULL;
g_win32_error_message (gint error)
{
gchar *retval;
-
- if (G_WIN32_HAVE_WIDECHAR_API ())
+ wchar_t *msg = NULL;
+ int nchars;
+
+ FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER
+ |FORMAT_MESSAGE_IGNORE_INSERTS
+ |FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL, error, 0,
+ (LPWSTR) &msg, 0, NULL);
+ if (msg != NULL)
{
- wchar_t *msg = NULL;
- int nchars;
-
- FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER
- |FORMAT_MESSAGE_IGNORE_INSERTS
- |FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, error, 0,
- (LPWSTR) &msg, 0, NULL);
- if (msg != NULL)
- {
- nchars = wcslen (msg);
-
- if (nchars > 2 && msg[nchars-1] == '\n' && msg[nchars-2] == '\r')
- msg[nchars-2] = '\0';
-
- retval = g_utf16_to_utf8 (msg, -1, NULL, NULL, NULL);
-
- LocalFree (msg);
- }
- else
- retval = g_strdup ("");
+ nchars = wcslen (msg);
+
+ if (nchars > 2 && msg[nchars-1] == '\n' && msg[nchars-2] == '\r')
+ msg[nchars-2] = '\0';
+
+ retval = g_utf16_to_utf8 (msg, -1, NULL, NULL, NULL);
+
+ LocalFree (msg);
}
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 ("");
- }
+ retval = g_strdup ("");
return retval;
}
gchar *fn;
gchar *p;
gchar *result;
+ wchar_t wc_fn[MAX_PATH];
G_LOCK (module_dirs);
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);
- }
+ 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);
+
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
+ if (!GetModuleFileNameW (hmodule, wc_fn, MAX_PATH))
{
- 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);
+ G_UNLOCK (module_dirs);
+ return NULL;
}
+ fn = g_utf16_to_utf8 (wc_fn, -1, NULL, NULL, NULL);
if ((p = strrchr (fn, G_DIR_SEPARATOR)) != NULL)
*p = '\0';
G_LOCK_DEFINE_STATIC (package_dirs);
gchar *result = NULL;
gchar *key;
+ wchar_t *wc_key;
HKEY reg_key = NULL;
DWORD type;
DWORD nbytes;
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);
- if (((RegOpenKeyExW (HKEY_CURRENT_USER, wc_key, 0,
- KEY_QUERY_VALUE, ®_key) == ERROR_SUCCESS
- && RegQueryValueExW (reg_key, L"InstallationDirectory", 0,
- &type, NULL, &nbytes) == ERROR_SUCCESS)
- ||
- (RegOpenKeyExW (HKEY_LOCAL_MACHINE, wc_key, 0,
- KEY_QUERY_VALUE, ®_key) == ERROR_SUCCESS
- && RegQueryValueExW (reg_key, L"InstallationDirectory", 0,
- &type, NULL, &nbytes) == ERROR_SUCCESS))
- && type == REG_SZ)
- {
- wchar_t *wc_temp = g_new (wchar_t, (nbytes+1)/2 + 1);
- RegQueryValueExW (reg_key, L"InstallationDirectory", 0,
- &type, (LPBYTE) wc_temp, &nbytes);
- wc_temp[nbytes/2] = '\0';
- result = g_utf16_to_utf8 (wc_temp, -1, NULL, NULL, NULL);
- g_free (wc_temp);
- }
- g_free (wc_key);
- }
- else
+
+ wc_key = g_utf8_to_utf16 (key, -1, NULL, NULL, NULL);
+ if (((RegOpenKeyExW (HKEY_CURRENT_USER, wc_key, 0,
+ KEY_QUERY_VALUE, ®_key) == ERROR_SUCCESS
+ && RegQueryValueExW (reg_key, L"InstallationDirectory", 0,
+ &type, NULL, &nbytes) == ERROR_SUCCESS)
+ ||
+ (RegOpenKeyExW (HKEY_LOCAL_MACHINE, wc_key, 0,
+ KEY_QUERY_VALUE, ®_key) == ERROR_SUCCESS
+ && RegQueryValueExW (reg_key, L"InstallationDirectory", 0,
+ &type, NULL, &nbytes) == ERROR_SUCCESS))
+ && type == REG_SZ)
{
- char *cp_key = g_locale_from_utf8 (key, -1, NULL, NULL, NULL);
- if (((RegOpenKeyExA (HKEY_CURRENT_USER, cp_key, 0,
- KEY_QUERY_VALUE, ®_key) == ERROR_SUCCESS
- && RegQueryValueExA (reg_key, "InstallationDirectory", 0,
- &type, NULL, &nbytes) == ERROR_SUCCESS)
- ||
- (RegOpenKeyExA (HKEY_LOCAL_MACHINE, cp_key, 0,
- KEY_QUERY_VALUE, ®_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);
+ wchar_t *wc_temp = g_new (wchar_t, (nbytes+1)/2 + 1);
+ RegQueryValueExW (reg_key, L"InstallationDirectory", 0,
+ &type, (LPBYTE) wc_temp, &nbytes);
+ wc_temp[nbytes/2] = '\0';
+ result = g_utf16_to_utf8 (wc_temp, -1, NULL, NULL, NULL);
+ g_free (wc_temp);
}
+ g_free (wc_key);
if (reg_key != NULL)
RegCloseKey (reg_key);
if (!beenhere)
{
beenhere = TRUE;
- if (getenv ("G_WIN32_PRETEND_WIN9X"))
- windows_version = 0x80000004;
- else
- windows_version = GetVersion ();
+ windows_version = GetVersion ();
+
+ if (windows_version & 0x80000000)
+ g_error ("This version of GLib requires NT-based Windows.");
}
}
* 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
{
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.
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
+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 ===
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);
-
- handle = LoadLibraryW (wfilename);
- g_free (wfilename);
- }
- else
- {
- gchar *cp_filename = g_locale_from_utf8 (file_name, -1, NULL, NULL, NULL);
+ wfilename = g_utf8_to_utf16 (file_name, -1, NULL, NULL, NULL);
- handle = LoadLibraryA (cp_filename);
- g_free (cp_filename);
- }
+ handle = LoadLibraryW (wfilename);
+ g_free (wfilename);
if (!handle)
set_error ();