Fix ws_stdio_unlink so it works properly on WIndows for all Unicode filenames.
- Essentially: ws_stdio_unlink would fail trying to delete any path\filename containing a Unicode character which could not be mapped to the "system codepage" (ie: to a character encoded with a value of 1-255). For example: ws_stdio_unlink was not able to delete a path\filename containing the character U+210B. - The problem: A copy/paste of the wrong (non-Windows) portion of the GLib g_unlink code was done when file_util.c was created. - The solution: replace the ws_stdio_unlink code with the correct code copied from the Glib g_unlink function. svn path=/trunk/; revision=27661
This commit is contained in:
parent
bb3b362089
commit
8837679be0
|
@ -249,7 +249,6 @@ ws_stdio_stat (const gchar *filename,
|
|||
errno = save_errno;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_unlink:
|
||||
* @filename: a pathname in the GLib file name encoding (UTF-8 on Windows)
|
||||
|
@ -268,23 +267,24 @@ ws_stdio_stat (const gchar *filename,
|
|||
*
|
||||
* Since: 2.6
|
||||
*/
|
||||
|
||||
int
|
||||
ws_stdio_unlink (const gchar *filename)
|
||||
{
|
||||
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
|
||||
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
||||
int retval;
|
||||
int save_errno;
|
||||
|
||||
if (cp_filename == NULL)
|
||||
if (wfilename == NULL)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
retval = unlink (cp_filename);
|
||||
retval = _wunlink (wfilename);
|
||||
save_errno = errno;
|
||||
|
||||
g_free (cp_filename);
|
||||
g_free (wfilename);
|
||||
|
||||
errno = save_errno;
|
||||
return retval;
|
||||
|
|
Loading…
Reference in New Issue