Convert filenames to UTF-8 before putting them in GErrors. (#154078,

2004-09-30  Matthias Clasen  <mclasen@redhat.com>

	* glib/gfileutils.c: Convert filenames to UTF-8 before
	putting them in GErrors.  (#154078, Morten Welinder)
This commit is contained in:
Matthias Clasen 2004-09-30 04:03:16 +00:00 committed by Matthias Clasen
parent 0455122b1a
commit ea58e960f9
6 changed files with 76 additions and 12 deletions

View 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.

View 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.

View 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.

View 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.

View 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.

View 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;
}