? glib/gdir.c.temp
? glib/gfileutf8.c
? glib/gfileutf8.h
? glib/giowin32.c.WORK
? glib/gmain.c.WORK
? glib/gmessages.c.1.43
? glib/gmessages.c.console-koe
? glib/gutils.c.home
? glib/gnulib/vasnprintf.c.huh
Index: glib/Makefile.am
===================================================================
RCS file: /cvs/gnome/glib/glib/Makefile.am,v
retrieving revision 1.114
diff -p -u -2 -r1.114 Makefile.am
--- glib/Makefile.am	2 Aug 2004 21:40:40 -0000	1.114
+++ glib/Makefile.am	13 Aug 2004 04:02:25 -0000
@@ -53,4 +53,5 @@ libglib_2_0_la_SOURCES = 	\
 	gdir.c			\
 	gerror.c		\
+	gfileutf8.c		\
 	gfileutils.c		\
 	ghash.c			\
@@ -122,4 +123,5 @@ glibsubinclude_HEADERS =   \
 	gdir.h		\
 	gerror.h	\
+	gfileutf8.h	\
 	gfileutils.h	\
 	ghash.h		\
Index: glib/gdir.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gdir.c,v
retrieving revision 1.10
diff -p -u -2 -r1.10 gdir.c
--- glib/gdir.c	9 Jul 2004 13:05:40 -0000	1.10
+++ glib/gdir.c	13 Aug 2004 04:02:26 -0000
@@ -5,4 +5,5 @@
  *
  * Copyright 2001 Hans Breuer
+ * Copyright 2004 Tor Lillqvist
  *
  * This library is free software; you can redistribute it and/or
@@ -37,7 +38,21 @@
 #include "glibintl.h"
 
+#ifdef G_OS_UNIX
+#ifdef NAME_MAX
+#define FILENAME_MAX NAME_MAX
+#else
+#define FILANAME_MAX 256
+#endif
+#endif
+
 struct _GDir
 {
-  DIR *dir;
+  gchar utf8_buf[FILENAME_MAX*4];
+  union {
+    DIR *dirp;
+#ifdef G_OS_WIN32
+    _WDIR *wdirp;
+#endif
+  } u;
 };
 
@@ -50,7 +65,7 @@ struct _GDir
  *         g_dir_open_fails.
  *
- * Opens a directory for reading. The names of the files
- * in the directory can then be retrieved using
- * g_dir_read_name().
+ * Opens a directory for reading. The names of the files in the
+ * directory can then be retrieved using g_dir_read_name() or
+ * g_dir_read_name_utf8().
  *
  * Return value: a newly allocated #GDir on success, %NULL on failure.
@@ -68,9 +83,24 @@ g_dir_open (const gchar  *path,
   g_return_val_if_fail (path != NULL, NULL);
 
+#ifdef G_OS_WIN32
+  if (G_WIN32_HAS_WIDECHAR_API ())
+    {
+      dir = NULL;
+
+      utf8_path = g_filename_to_utf8 (path, -1, NULL, NULL, error);
+      if (utf8_path != NULL)
+	dir = g_dir_open_utf8 (utf8_path, flags, error);
+      
+      g_free (utf8_path);
+      
+      return dir;
+    }
+#endif
+
   dir = g_new (GDir, 1);
 
-  dir->dir = opendir (path);
+  dir->u.dirp = opendir (path);
 
-  if (dir->dir)
+  if (dir->u.dirp)
     return dir;
 
@@ -91,13 +121,81 @@ g_dir_open (const gchar  *path,
 
 /**
+ * g_dir_open_utf8:
+ * @path_utf8: the path to the directory you are interested in, in UTF-8
+ * @flags: Currently must be set to 0. Reserved for future use.
+ * @error: return location for a #GError, or %NULL.
+ *         If non-%NULL, an error will be set if and only if
+ *         g_dir_open_fails.
+ *
+ * Opens a directory for reading. The names of the files in the
+ * directory can then be retrieved using g_dir_read_name() or
+ * g_dir_read_name_utf8().
+ *
+ * Return value: a newly allocated #GDir on success, %NULL on failure.
+ *   If non-%NULL, you must free the result with g_dir_close()
+ *   when you are finished with it.
+ *
+ * Since: 2.6
+ **/
+GDir *
+g_dir_open_utf8 (const gchar  *path_utf8,
+		 guint         flags,
+		 GError      **error)
+{
+  GDir *dir = NULL;
+  gchar *path;
+
+  g_return_val_if_fail (path_utf8 != NULL, NULL);
+
+#ifdef G_OS_WIN32
+  if (G_WIN32_HAS_WIDECHAR_API ())
+    {
+      wchar_t *wpath = g_utf8_to_utf16 (path_utf8, -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;
+
+      /* error case */
+
+      g_set_error (error,
+		   G_FILE_ERROR,
+		   g_file_error_from_errno (errno),
+		   _("Error opening directory '%s': %s"),
+		   path_utf8, g_strerror (errno));
+
+      g_free (dir);
+      
+      return NULL;
+    }
+#endif
+
+  path = g_filename_from_utf8 (path_utf8, -1, NULL, NULL, error);
+  if (path != NULL)
+    dir = g_dir_open (path, flags, error);
+
+  g_free (path);
+
+  return dir;
+}
+
+/**
  * g_dir_read_name:
- * @dir: a #GDir* created by g_dir_open()
+ * @dir: a #GDir* created by g_dir_open() or g_dir_open_utf8()
  *
- * Retrieves the name of the next entry in the directory.
- * The '.' and '..' entries are omitted. The returned name is in 
- * the encoding used for filenames. Use g_filename_to_utf8() to 
- * convert it to UTF-8.
+ * Retrieves the name of the next entry in the directory.  The '.' and
+ * '..' entries are omitted. The returned name is in the encoding used
+ * for filenames. On Windows, entries whose name can't be expressed in
+ * the system codepage are omitted. Use g_dir_read_name_utf8() to
+ * retrieve names in UTF-8.
  *
- * Return value: The entries name or %NULL if there are no 
+ * Return value: The entry's name or %NULL if there are no 
  *   more entries. The return value is owned by GLib and
  *   must not be modified or freed.
@@ -110,9 +208,38 @@ g_dir_read_name (GDir *dir)
   g_return_val_if_fail (dir != NULL, NULL);
 
-  entry = readdir (dir->dir);
+#ifdef G_OS_WIN32
+  if (G_WIN32_HAS_WIDECHAR_API ())
+    {
+      const gchar *name_utf8;
+      gchar *name;
+
+      while (1)
+	{
+	  name_utf8 = (gchar *) g_dir_read_name_utf8 (dir);
+      
+	  if (name_utf8 == NULL)
+	    return NULL;
+	  
+	  name = g_filename_from_utf8 (name_utf8, -1, NULL, NULL, NULL);
+	  
+	  if (name == NULL)
+	    continue;		/* Skip names not expressable in the system codepage */
+
+	  /* UTF-8 strings are never shorter than their system
+	   * codepage equivalents, so it must fit.
+	   */
+	  strcpy (dir->utf8_buf, name);
+	  g_free (name);
+	  
+	  return dir->utf8_buf;
+	}
+    }
+#endif  
+
+  entry = readdir (dir->u.dirp);
   while (entry 
          && (0 == strcmp (entry->d_name, ".") ||
              0 == strcmp (entry->d_name, "..")))
-    entry = readdir (dir->dir);
+    entry = readdir (dir->u.dirp);
 
   if (entry)
@@ -123,9 +250,80 @@ g_dir_read_name (GDir *dir)
 
 /**
+ * g_dir_read_name_utf8:
+ * @dir: a #GDir* created by g_dir_open() or g_dir_open_utf8()
+ *
+ * Retrieves the name of the next entry in the directory.  The '.' and
+ * '..' entries are omitted. The returned name is in UTF-8.
+ *
+ * Return value: The entry's name or %NULL if there are no 
+ *   more entries. The return value is owned by GLib and
+ *   must not be modified or freed.
+ *
+ * Since: 2.6
+ **/
+G_CONST_RETURN gchar*
+g_dir_read_name_utf8 (GDir *dir)
+{
+  gchar *name;
+  gchar *name_utf8;
+
+  g_return_val_if_fail (dir != NULL, NULL);
+
+#ifdef G_OS_WIN32
+
+  if (G_WIN32_HAS_WIDECHAR_API ())
+    {
+      struct _wdirent *entry;
+
+      while (1)
+	{
+	  entry = _wreaddir (dir->u.wdirp);
+	  while (entry 
+		 && (0 == wcscmp (entry->d_name, L".") ||
+		     0 == wcscmp (entry->d_name, L"..")))
+	    entry = _wreaddir (dir->u.wdirp);
+	  
+	  if (entry == NULL)
+	    return NULL;
+	  
+	  name_utf8 = g_utf16_to_utf8 (entry->d_name, -1, NULL, NULL, NULL);
+
+
+	  if (name_utf8 == NULL)
+	    continue;		/* Huh, impossible? Skip it anyway */
+	  
+	  strcpy (dir->utf8_buf, name_utf8);
+	  g_free (name_utf8);
+	  
+	  return dir->utf8_buf;
+	}
+    }
+#endif
+
+  while (1)
+    {
+      name = g_dir_read_name (dir);
+
+      if (name == NULL)
+	return NULL;
+
+      name_utf8 = g_filename_to_utf8 (name, -1, NULL, NULL, NULL);
+
+      if (name_utf8 != NULL)
+	{
+	  strcpy (dir->utf8_buf, name_utf8);
+	  g_free (name_utf8);
+
+	  return dir->utf8_buf;
+	}
+    }
+}
+
+/**
  * g_dir_rewind:
- * @dir: a #GDir* created by g_dir_open()
+ * @dir: a #GDir* created by g_dir_open() or g_dir_open_utf8()
  *
- * Resets the given directory. The next call to g_dir_read_name()
- * will return the first entry again.
+ * Resets the given directory. The next call to g_dir_read_name() or
+ * g_dir_read_name_utf8() will return the first entry again.
  **/
 void
@@ -134,10 +332,18 @@ g_dir_rewind (GDir *dir)
   g_return_if_fail (dir != NULL);
   
-  rewinddir (dir->dir);
+#ifdef G_OS_WIN32
+  if (G_WIN32_HAS_WIDECHAR_API ())
+    {
+      _wrewinddir (dir->u.wdirp);
+      return;
+    }
+#endif
+
+  rewinddir (dir->u.dirp);
 }
 
 /**
  * g_dir_close:
- * @dir: a #GDir* created by g_dir_open()
+ * @dir: a #GDir* created by g_dir_open() or g_dir_open_utf8()
  *
  * Closes the directory and deallocates all related resources.
@@ -148,5 +354,14 @@ g_dir_close (GDir *dir)
   g_return_if_fail (dir != NULL);
 
-  closedir (dir->dir);
+#ifdef G_OS_WIN32
+  if (G_WIN32_HAS_WIDECHAR_API ())
+    {
+      _wclosedir (dir->u.wdirp);
+      g_free (dir);
+      return;
+    }
+#endif
+
+  closedir (dir->u.dirp);
   g_free (dir);
 }
Index: glib/gdir.h
===================================================================
RCS file: /cvs/gnome/glib/glib/gdir.h,v
retrieving revision 1.3
diff -p -u -2 -r1.3 gdir.h
--- glib/gdir.h	22 Nov 2002 23:45:32 -0000	1.3
+++ glib/gdir.h	13 Aug 2004 04:02:26 -0000
@@ -30,10 +30,14 @@ G_BEGIN_DECLS
 typedef struct _GDir GDir;
 
-GDir    *               g_dir_open      (const gchar  *path,
-					 guint         flags,
-					 GError      **error);
-G_CONST_RETURN gchar   *g_dir_read_name (GDir         *dir);
-void                    g_dir_rewind    (GDir         *dir);
-void                    g_dir_close     (GDir         *dir);
+GDir    *               g_dir_open           (const gchar  *path,
+					      guint         flags,
+					      GError      **error);
+GDir    *               g_dir_open_utf8      (const gchar  *path_utf8,
+					      guint         flags,
+					      GError      **error);
+G_CONST_RETURN gchar   *g_dir_read_name      (GDir         *dir);
+G_CONST_RETURN gchar   *g_dir_read_name_utf8 (GDir         *dir);
+void                    g_dir_rewind         (GDir         *dir);
+void                    g_dir_close          (GDir         *dir);
 
 G_END_DECLS
Index: glib/gfileutils.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gfileutils.c,v
retrieving revision 1.43
diff -p -u -2 -r1.43 gfileutils.c
--- glib/gfileutils.c	14 Dec 2003 19:05:29 -0000	1.43
+++ glib/gfileutils.c	13 Aug 2004 04:02:26 -0000
@@ -182,4 +182,75 @@ g_file_test (const gchar *filename,
 }
 
+/**
+ * g_file_test_utf8:
+ * @filename_utf8: a filename to test
+ * @test: bitfield of #GFileTest flags
+ * 
+ * Like g_file_test, but takes a filename in UTF-8.
+ * Return value: whether a test was %TRUE
+ *
+ * Since: 2.6
+ **/
+gboolean
+g_file_test_utf8 (const gchar *filename_utf8,
+		  GFileTest    test)
+{
+  gchar *filename;
+  gboolean retval;
+
+#ifdef G_OS_WIN32
+  if (G_WIN32_HAS_WIDECHAR_API ())
+    {
+      wchar_t *wfilename = g_utf8_to_utf16 (filename_utf8, -1, NULL, NULL, NULL);
+
+      if (wfilename == NULL)
+	return FALSE;
+
+      if ((test & G_FILE_TEST_EXISTS) && (_waccess (wfilename, F_OK) == 0))
+	{
+	  g_free (wfilename);
+	  return TRUE;
+	}
+      
+      if (test & (G_FILE_TEST_IS_REGULAR |
+		  G_FILE_TEST_IS_DIR |
+		  G_FILE_TEST_IS_EXECUTABLE))
+	{
+	  struct stat s;
+	  
+	  if (_wstat (wfilename, &s) == 0)
+	    {
+	      g_free (wfilename);
+	      
+	      if ((test & G_FILE_TEST_IS_REGULAR) && S_ISREG (s.st_mode))
+		return TRUE;
+	      
+	      if ((test & G_FILE_TEST_IS_DIR) && S_ISDIR (s.st_mode))
+		return TRUE;
+	      
+	      if ((test & G_FILE_TEST_IS_EXECUTABLE) &&
+		  (s.st_mode & _S_IEXEC))
+		return TRUE;
+	    }
+	}
+
+      g_free (wfilename);
+      
+      return FALSE;
+    }
+#endif
+
+  filename = g_filename_from_utf8 (filename_utf8, -1, NULL, NULL, NULL);
+
+  if (filename == NULL)
+    return FALSE;
+
+  retval = g_file_test (filename, test);
+
+  g_free (filename);
+
+  return retval;
+}
+
 GQuark
 g_file_error_quark (void)
@@ -357,5 +428,5 @@ g_file_error_from_errno (gint err_no)
 
 static gboolean
-get_contents_stdio (const gchar *filename,
+get_contents_stdio (const gchar *utf8_filename,
                     FILE        *f,
                     gchar      **contents,
@@ -392,5 +463,5 @@ get_contents_stdio (const gchar *filenam
                            G_FILE_ERROR_NOMEM,
                            _("Could not allocate %lu bytes to read file \"%s\""),
-                           (gulong) total_allocated, filename);
+                           (gulong) total_allocated, utf8_filename);
               goto error;
             }
@@ -403,5 +474,5 @@ get_contents_stdio (const gchar *filenam
                        g_file_error_from_errno (errno),
                        _("Error reading file '%s': %s"),
-                       filename, g_strerror (errno));
+                       utf8_filename, g_strerror (errno));
 
           goto error;
@@ -434,5 +505,5 @@ get_contents_stdio (const gchar *filenam
 
 static gboolean
-get_contents_regfile (const gchar *filename,
+get_contents_regfile (const gchar *utf8_filename,
                       struct stat *stat_buf,
                       gint         fd,
@@ -457,5 +528,5 @@ get_contents_regfile (const gchar *filen
                    G_FILE_ERROR_NOMEM,
                    _("Could not allocate %lu bytes to read file \"%s\""),
-                   (gulong) alloc_size, filename);
+                   (gulong) alloc_size, utf8_filename);
 
       goto error;
@@ -479,5 +550,5 @@ get_contents_regfile (const gchar *filen
                            g_file_error_from_errno (errno),
                            _("Failed to read from file '%s': %s"),
-                           filename, g_strerror (errno));
+                           utf8_filename, g_strerror (errno));
 
 	      goto error;
@@ -516,5 +587,8 @@ get_contents_posix (const gchar *filenam
   struct stat stat_buf;
   gint fd;
+  gchar *utf8_filename;
   
+  utf8_filename = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
+
   /* O_BINARY useful on Cygwin */
   fd = open (filename, O_RDONLY|O_BINARY);
@@ -526,5 +600,6 @@ get_contents_posix (const gchar *filenam
                    g_file_error_from_errno (errno),
                    _("Failed to open file '%s': %s"),
-                   filename, g_strerror (errno));
+                   utf8_filename, g_strerror (errno));
+      g_free (utf8_filename);
 
       return FALSE;
@@ -540,5 +615,6 @@ get_contents_posix (const gchar *filenam
                    g_file_error_from_errno (errno),
                    _("Failed to get attributes of file '%s': fstat() failed: %s"),
-                   filename, g_strerror (errno));
+                   utf8_filename, g_strerror (errno));
+      g_free (utf8_filename);
 
       return FALSE;
@@ -547,14 +623,18 @@ get_contents_posix (const gchar *filenam
   if (stat_buf.st_size > 0 && S_ISREG (stat_buf.st_mode))
     {
-      return get_contents_regfile (filename,
-                                   &stat_buf,
-                                   fd,
-                                   contents,
-                                   length,
-                                   error);
+      gboolean retval = get_contents_regfile (utf8_filename,
+					      &stat_buf,
+					      fd,
+					      contents,
+					      length,
+					      error);
+      g_free (utf8_filename);
+
+      return retval;
     }
   else
     {
       FILE *f;
+      gboolean retval;
 
       f = fdopen (fd, "r");
@@ -566,10 +646,14 @@ get_contents_posix (const gchar *filenam
                        g_file_error_from_errno (errno),
                        _("Failed to open file '%s': fdopen() failed: %s"),
-                       filename, g_strerror (errno));
+                       utf8_filename, g_strerror (errno));
+	  g_free (utf8_filename);
           
           return FALSE;
         }
   
-      return get_contents_stdio (filename, f, contents, length, error);
+      retval = get_contents_stdio (utf8_filename, f, contents, length, error);
+      g_free (utf8_filename);
+
+      return retval;
     }
 }
@@ -584,4 +668,8 @@ get_contents_win32 (const gchar *filenam
 {
   FILE *f;
+  gchar *utf8_filename;
+  gboolean retval;
+  
+  utf8_filename = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
 
   /* I guess you want binary mode; maybe you want text sometimes? */
@@ -594,10 +682,43 @@ get_contents_win32 (const gchar *filenam
                    g_file_error_from_errno (errno),
                    _("Failed to open file '%s': %s"),
-                   filename, g_strerror (errno));
+                   utf8_filename, g_strerror (errno));
+      g_free (utf8_filename);
       
       return FALSE;
     }
   
-  return get_contents_stdio (filename, f, contents, length, error);
+  retval = get_contents_stdio (utf8_filename, f, contents, length, error);
+  g_free (utf8_filename);
+
+  return retval;
+}
+
+static gboolean
+get_contents_win32_utf8 (const gchar *filename_utf8,
+			 gchar      **contents,
+			 gsize       *length,
+			 GError     **error)
+{
+  FILE *f;
+  gboolean retval;
+  wchar_t *wfilename = g_utf8_to_utf16 (filename_utf8, -1, NULL, NULL, NULL);
+  
+  f = _wfopen (wfilename, L"rb");
+  g_free (wfilename);
+
+  if (f == NULL)
+    {
+      g_set_error (error,
+                   G_FILE_ERROR,
+                   g_file_error_from_errno (errno),
+                   _("Failed to open file '%s': %s"),
+                   filename_utf8, g_strerror (errno));
+      
+      return FALSE;
+    }
+  
+  retval = get_contents_stdio (filename_utf8, f, contents, length, error);
+
+  return retval;
 }
 
@@ -606,5 +727,5 @@ get_contents_win32 (const gchar *filenam
 /**
  * g_file_get_contents:
- * @filename: a file to read contents from
+ * @filename: name of a file to read contents from, in the encoding used for filenames
  * @contents: location to store an allocated string
  * @length: location to store length in bytes of the contents
@@ -641,4 +762,45 @@ g_file_get_contents (const gchar *filena
 }
 
+/**
+ * g_file_get_contents_utf8:
+ *
+ * Like g_file_get_contents, but takes the file name in UTF-8.
+ *
+ * Return value: %TRUE on success, %FALSE if error is set
+ *
+ * Since: 2.6
+ **/
+gboolean
+g_file_get_contents_utf8 (const gchar *filename_utf8,
+			  gchar      **contents,
+			  gsize       *length,
+			  GError     **error)
+{  
+  gchar *filename;
+  gboolean retval;
+
+  g_return_val_if_fail (filename_utf8 != NULL, FALSE);
+  g_return_val_if_fail (contents != NULL, FALSE);
+
+  *contents = NULL;
+  if (length)
+    *length = 0;
+
+#ifdef G_OS_WIN32
+  if (G_WIN32_HAS_WIDECHAR_API ())
+    return get_contents_win32_utf8 (filename_utf8, contents, length, error);
+#endif
+
+  filename = g_filename_from_utf8 (filename_utf8, -1, NULL, NULL, NULL);
+#ifdef G_OS_WIN32
+  return get_contents_win32 (filename, contents, length, error);
+#else
+  retval = get_contents_posix (filename, contents, length, error);
+#endif
+  g_free (filename);
+
+  return retval;
+}
+
 /*
  * mkstemp() implementation is from the GNU C library.
@@ -1147,4 +1309,5 @@ g_file_read_link (const gchar *filename,
       read_size = readlink (filename, buffer, size);
       if (read_size < 0) {
+	gchar *utf8_filename = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
 	g_free (buffer);
 	g_set_error (error,
@@ -1152,5 +1315,6 @@ g_file_read_link (const gchar *filename,
 		     g_file_error_from_errno (errno),
 		     _("Failed to read the symbolic link '%s': %s"),
-		     filename, g_strerror (errno));
+		     utf8_filename, g_strerror (errno));
+	g_free (utf8_filename);
 	
 	return NULL;
@@ -1166,4 +1330,45 @@ g_file_read_link (const gchar *filename,
       buffer = g_realloc (buffer, size);
     }
+#else
+  g_set_error (error,
+	       G_FILE_ERROR,
+	       G_FILE_ERROR_INVAL,
+	       _("Symbolic links not supported"));
+	
+  return NULL;
+#endif
+}
+
+/**
+ * g_file_read_link_utf8:
+ *
+ * Like g_file_read_link, but takes the file name argument in UTF-8,
+ * and returns the result in UTF-8.
+ *
+ * Since: 2.6
+ */
+gchar *
+g_file_read_link_utf8 (const gchar *filename_utf8,
+		       GError     **error)
+{
+#ifdef HAVE_READLINK
+  gchar *filename;
+  gchar *link;
+  gchar *retval;
+  
+  filename = g_filename_from_utf8 (filename_utf8, -1, NULL, NULL, error);
+  if (filename == NULL)
+    return NULL;
+
+  link = g_file_read_link (filename, error);
+  g_free (filename);
+
+  if (link == NULL)
+    return NULL;
+
+  retval = g_filename_to_utf8 (link, -1, NULL, NULL, error);
+  g_free (link);
+
+  return retval;
 #else
   g_set_error (error,
Index: glib/gfileutils.h
===================================================================
RCS file: /cvs/gnome/glib/glib/gfileutils.h,v
retrieving revision 1.12
diff -p -u -2 -r1.12 gfileutils.h
--- glib/gfileutils.h	29 Jul 2003 22:31:39 -0000	1.12
+++ glib/gfileutils.h	13 Aug 2004 04:02:26 -0000
@@ -96,7 +96,22 @@ gchar *g_build_filename (const gchar *fi
 			 ...);
 
-G_END_DECLS
+/* UTF-8 versions */
 
-#endif /* __G_FILEUTILS_H__ */
+gboolean g_file_test_utf8         (const gchar  *filename_utf8,
+				   GFileTest     test);
+gboolean g_file_get_contents_utf8 (const gchar  *filename_utf8,
+				   gchar       **contents,
+				   gsize        *length,    
+				   GError      **error);
+gchar   *g_file_read_link_utf8    (const gchar  *filename_utf8,
+				   GError      **error);
+
+gint    g_mkstemp_utf8            (gchar        *tmpl_utf8);
 
+gint    g_file_open_tmp_utf8      (const gchar  *tmpl_utf8,
+				   gchar       **name_used_utf8,
+				   GError      **error);
 
+G_END_DECLS
+
+#endif /* __G_FILEUTILS_H__ */
Index: glib/gutils.h
===================================================================
RCS file: /cvs/gnome/glib/glib/gutils.h,v
retrieving revision 1.20
diff -p -u -2 -r1.20 gutils.h
--- glib/gutils.h	3 Aug 2004 19:41:02 -0000	1.20
+++ glib/gutils.h	13 Aug 2004 04:02:27 -0000
@@ -117,9 +117,15 @@ G_CONST_RETURN gchar* g_get_user_name   
 G_CONST_RETURN gchar* g_get_real_name        (void);
 G_CONST_RETURN gchar* g_get_home_dir         (void);
+G_CONST_RETURN gchar* g_get_home_dir_utf8    (void);
 G_CONST_RETURN gchar* g_get_tmp_dir          (void);
+G_CONST_RETURN gchar* g_get_tmp_dir_utf8     (void);
 gchar*                g_get_prgname          (void);
+gchar*                g_get_prgname_utf8     (void);
 void                  g_set_prgname          (const gchar *prgname);
+void                  g_set_prgname_utf8     (const gchar *prgname_utf8);
 G_CONST_RETURN gchar* g_get_application_name (void);
+G_CONST_RETURN gchar* g_get_application_name_utf8 (void);
 void                  g_set_application_name (const gchar *application_name);
+void                  g_set_application_name_utf8 (const gchar *application_name_utf8);
 
 
@@ -165,4 +171,5 @@ G_CONST_RETURN gchar* g_basename        
 /* The returned strings are newly allocated with g_malloc() */
 gchar*                g_get_current_dir    (void);
+gchar*                g_get_current_dir_utf8 (void);
 gchar*                g_path_get_basename  (const gchar *file_name);
 gchar*                g_path_get_dirname   (const gchar *file_name);
Index: glib/gwin32.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gwin32.c,v
retrieving revision 1.38
diff -p -u -2 -r1.38 gwin32.c
--- glib/gwin32.c	25 Apr 2004 22:51:46 -0000	1.38
+++ glib/gwin32.c	13 Aug 2004 04:02:29 -0000
@@ -1298,2 +1298,18 @@ g_win32_get_package_installation_subdire
   return dirname;
 }
+
+guint
+g_win32_get_windows_version (void)
+{
+  static gboolean beenhere = FALSE;
+  static guint version;
+
+  if (!beenhere)
+    {
+      version = GetVersion ();
+      if (getenv ("PRETEND_WIN9X"))
+	version = 0x80000004;
+      beenhere = TRUE;
+    }
+  return version;
+}
Index: glib/gwin32.h
===================================================================
RCS file: /cvs/gnome/glib/glib/gwin32.h,v
retrieving revision 1.9
diff -p -u -2 -r1.9 gwin32.h
--- glib/gwin32.h	2 Jan 2003 00:30:22 -0000	1.9
+++ glib/gwin32.h	13 Aug 2004 04:02:29 -0000
@@ -94,4 +94,8 @@ gchar*          g_win32_get_package_inst
 							       gchar *subdir);
 
+guint		g_win32_get_windows_version (void);
+
+#define G_WIN32_HAS_WIDECHAR_API() (g_win32_get_windows_version () < 0x80000000)
+
 G_END_DECLS
 
