Convert filenames to UTF-8 before putting them in GErrors. (#154078,
authorMatthias Clasen <mclasen@redhat.com>
Thu, 30 Sep 2004 04:03:16 +0000 (04:03 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 30 Sep 2004 04:03:16 +0000 (04:03 +0000)
2004-09-30  Matthias Clasen  <mclasen@redhat.com>

* glib/gfileutils.c: Convert filenames to UTF-8 before
putting them in GErrors.  (#154078, Morten Welinder)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gfileutils.c

index daad4fbabf4815aa73a845759df93ad3ed4715e1..ec5451a74587e7090aa5b5f7da7ed1a58d30f18e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-09-30  Matthias Clasen  <mclasen@redhat.com>
+
+       * glib/gfileutils.c: Convert filenames to UTF-8 before 
+       putting them in GErrors.  (#154078, Morten Welinder)
+
 2004-09-29  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/glib.symbols: Add g_assert_warning.
index daad4fbabf4815aa73a845759df93ad3ed4715e1..ec5451a74587e7090aa5b5f7da7ed1a58d30f18e 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-30  Matthias Clasen  <mclasen@redhat.com>
+
+       * glib/gfileutils.c: Convert filenames to UTF-8 before 
+       putting them in GErrors.  (#154078, Morten Welinder)
+
 2004-09-29  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/glib.symbols: Add g_assert_warning.
index daad4fbabf4815aa73a845759df93ad3ed4715e1..ec5451a74587e7090aa5b5f7da7ed1a58d30f18e 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-30  Matthias Clasen  <mclasen@redhat.com>
+
+       * glib/gfileutils.c: Convert filenames to UTF-8 before 
+       putting them in GErrors.  (#154078, Morten Welinder)
+
 2004-09-29  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/glib.symbols: Add g_assert_warning.
index daad4fbabf4815aa73a845759df93ad3ed4715e1..ec5451a74587e7090aa5b5f7da7ed1a58d30f18e 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-30  Matthias Clasen  <mclasen@redhat.com>
+
+       * glib/gfileutils.c: Convert filenames to UTF-8 before 
+       putting them in GErrors.  (#154078, Morten Welinder)
+
 2004-09-29  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/glib.symbols: Add g_assert_warning.
index daad4fbabf4815aa73a845759df93ad3ed4715e1..ec5451a74587e7090aa5b5f7da7ed1a58d30f18e 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-30  Matthias Clasen  <mclasen@redhat.com>
+
+       * glib/gfileutils.c: Convert filenames to UTF-8 before 
+       putting them in GErrors.  (#154078, Morten Welinder)
+
 2004-09-29  Matthias Clasen  <mclasen@redhat.com>
 
        * glib/glib.symbols: Add g_assert_warning.
index cfe1a09cd0ed9c7ff95a2a123bfe4580939134ea..b2e5a90a68fea3f5c2f1668fbc0b9976fb1b3d83 100644 (file)
@@ -394,22 +394,31 @@ get_contents_stdio (const gchar *filename,
 
           if (str == NULL)
             {
+             gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
+                                                        NULL, NULL, NULL);
               g_set_error (error,
                            G_FILE_ERROR,
                            G_FILE_ERROR_NOMEM,
                            _("Could not allocate %lu bytes to read file \"%s\""),
-                           (gulong) total_allocated, filename);
+                           (gulong) total_allocated, 
+                          utf8_filename ? utf8_filename : "???");
+             g_free (utf8_filename);
+
               goto error;
             }
         }
       
       if (ferror (f))
         {
+         gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
+                                                    NULL, NULL, NULL);
           g_set_error (error,
                        G_FILE_ERROR,
                        g_file_error_from_errno (errno),
                        _("Error reading file '%s': %s"),
-                       filename, g_strerror (errno));
+                       utf8_filename ? utf8_filename : "???", 
+                      g_strerror (errno));
+         g_free (utf8_filename);
 
           goto error;
         }
@@ -459,11 +468,15 @@ get_contents_regfile (const gchar *filename,
 
   if (buf == NULL)
     {
+      gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
+                                                NULL, NULL, NULL);
       g_set_error (error,
                    G_FILE_ERROR,
                    G_FILE_ERROR_NOMEM,
                    _("Could not allocate %lu bytes to read file \"%s\""),
-                   (gulong) alloc_size, filename);
+                   (gulong) alloc_size, 
+                  utf8_filename ? utf8_filename : "???");
+      g_free (utf8_filename);
 
       goto error;
     }
@@ -480,12 +493,15 @@ get_contents_regfile (const gchar *filename,
           if (errno != EINTR) 
             {
               g_free (buf);
-                  
+             gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
+                                                        NULL, NULL, NULL);
               g_set_error (error,
                            G_FILE_ERROR,
                            g_file_error_from_errno (errno),
                            _("Failed to read from file '%s': %s"),
-                           filename, g_strerror (errno));
+                           utf8_filename ? utf8_filename : "???", 
+                          g_strerror (errno));
+             g_free (utf8_filename);
 
              goto error;
             }
@@ -528,11 +544,15 @@ get_contents_posix (const gchar *filename,
 
   if (fd < 0)
     {
+      gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
+                                                NULL, NULL, NULL);
       g_set_error (error,
                    G_FILE_ERROR,
                    g_file_error_from_errno (errno),
                    _("Failed to open file '%s': %s"),
-                   filename, g_strerror (errno));
+                   utf8_filename ? utf8_filename : "???", 
+                  g_strerror (errno));
+      g_free (utf8_filename);
 
       return FALSE;
     }
@@ -542,11 +562,15 @@ get_contents_posix (const gchar *filename,
     {
       close (fd);
       
+      gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
+                                                NULL, NULL, NULL);
       g_set_error (error,
                    G_FILE_ERROR,
                    g_file_error_from_errno (errno),
                    _("Failed to get attributes of file '%s': fstat() failed: %s"),
-                   filename, g_strerror (errno));
+                   utf8_filename ? utf8_filename : "???", 
+                  g_strerror (errno));
+      g_free (utf8_filename);
 
       return FALSE;
     }
@@ -568,12 +592,17 @@ get_contents_posix (const gchar *filename,
       
       if (f == NULL)
         {
+         gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
+                                                    NULL, NULL, NULL);
+
           g_set_error (error,
                        G_FILE_ERROR,
                        g_file_error_from_errno (errno),
                        _("Failed to open file '%s': fdopen() failed: %s"),
-                       filename, g_strerror (errno));
-          
+                       utf8_filename ? utf8_filename : "???", 
+                      g_strerror (errno));
+          g_free (utf8_filename);
+
           return FALSE;
         }
   
@@ -596,12 +625,17 @@ get_contents_win32 (const gchar *filename,
 
   if (f == NULL)
     {
+      gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
+                                                NULL, NULL, NULL);
+      
       g_set_error (error,
                    G_FILE_ERROR,
                    g_file_error_from_errno (errno),
                    _("Failed to open file '%s': %s"),
-                   filename, g_strerror (errno));
-      
+                   utf8_filename ? utf8_filename : "???", 
+                  g_strerror (errno));
+      g_free (utf8_filename);
+
       return FALSE;
     }
   
@@ -1154,11 +1188,16 @@ g_file_read_link (const gchar *filename,
       read_size = readlink (filename, buffer, size);
       if (read_size < 0) {
        g_free (buffer);
+      
+       gchar *utf8_filename = g_filename_to_utf8 (filename, -1,
+                                                  NULL, NULL, NULL);
        g_set_error (error,
                     G_FILE_ERROR,
                     g_file_error_from_errno (errno),
                     _("Failed to read the symbolic link '%s': %s"),
-                    filename, g_strerror (errno));
+                    utf8_filename ? utf8_filename : "???", 
+                    g_strerror (errno));
+       g_free (utf8_filename);
        
        return NULL;
       }