[libchamplain] Make the windows mkdtemp be robust with non-ascii characters too



commit 9d49ac6b5d086958f0914aeaada3091bcc63b883
Author: Fridrich Å trba <fridrich strba bluewin ch>
Date:   Thu Apr 22 17:01:04 2010 +0200

    Make the windows mkdtemp be robust with non-ascii characters too

 champlain/champlain-file-cache.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/champlain/champlain-file-cache.c b/champlain/champlain-file-cache.c
index 8afbce9..f0d1f97 100644
--- a/champlain/champlain-file-cache.c
+++ b/champlain/champlain-file-cache.c
@@ -222,10 +222,26 @@ create_cache_dir (const gchar *dir_name)
 
 #ifdef G_OS_WIN32
 #include <io.h>
+#include <glib/gstdio.h>
 static char *mkdtemp(char *template)
 {
-	if (!_mktemp(template) || mkdir(template))
+	gunichar2 *wtemplate;
+	gchar *tmpl;
+	if (!template)
 		return NULL;
+	wtemplate = g_utf8_to_utf16 (template, -1, NULL, NULL, NULL);
+	if (!_wmktemp (wtemplate)) {
+		g_free (wtemplate);
+		return NULL;
+	}
+	tmpl = g_utf16_to_utf8 (wtemplate, -1, NULL, NULL, NULL);
+	g_free (wtemplate);
+	if ((strlen (template) != strlen (tmpl)) || g_mkdir (tmpl, 0700)) {
+		g_free (tmpl);
+		return NULL;
+	}
+	strcpy (template,tmpl);
+	g_free (tmpl);
 	return template;
 }
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]