aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2009-03-08 22:12:13 +0000
committerBill Meier <wmeier@newsguy.com>2009-03-08 22:12:13 +0000
commit8837679be034998349714a372513d3f4ded2d8f8 (patch)
tree4a0b0834ec08aba3682239cbcc6f3fef0237a7e0 /wsutil
parentbb3b3620896903b141516263c40d2e9dbdaf55e9 (diff)
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
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/file_util.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/wsutil/file_util.c b/wsutil/file_util.c
index 4e46131fa6..d145752c83 100644
--- a/wsutil/file_util.c
+++ b/wsutil/file_util.c
@@ -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;