changeset 16869:ec79e3ad09a9

_mktmp() sucks, so use g_mkstemp() instead. This probably doesn't have to be done differently for win32 and elsewhere, but I don't want to be changing things right now.
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 04 May 2007 04:01:23 +0000
parents f5d699d95744
children ce2422ae793c 86ba72a2b31e
files libpurple/util.c
diffstat 1 files changed, 5 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/util.c	Fri May 04 03:44:00 2007 +0000
+++ b/libpurple/util.c	Fri May 04 04:01:23 2007 +0000
@@ -2522,9 +2522,7 @@
 purple_mkstemp(char **fpath, gboolean binary)
 {
 	const gchar *tmpdir;
-#ifndef _WIN32
 	int fd;
-#endif
 	FILE *fp = NULL;
 
 	g_return_val_if_fail(fpath != NULL, NULL);
@@ -2532,19 +2530,11 @@
 	if((tmpdir = (gchar*)g_get_tmp_dir()) != NULL) {
 		if((*fpath = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", tmpdir, purple_mkstemp_templ)) != NULL) {
 #ifdef _WIN32
-			char* result = _mktemp( *fpath );
-			if( result == NULL )
-				purple_debug(PURPLE_DEBUG_ERROR, "purple_mkstemp",
-						   "Problem creating the template\n");
-			else
-			{
-				if( (fp = g_fopen( result, binary?"wb+":"w+")) == NULL ) {
-					purple_debug(PURPLE_DEBUG_ERROR, "purple_mkstemp",
-							   "Couldn't fopen() %s\n", result);
-				}
-			}
+			fd = g_mkstemp(*fpath);
 #else
-			if((fd = mkstemp(*fpath)) == -1) {
+			fd = mkstemp(*fpath));
+#endif
+			if(fd == -1) {
 				purple_debug(PURPLE_DEBUG_ERROR, "purple_mkstemp",
 						   "Couldn't make \"%s\", error: %d\n",
 						   *fpath, errno);
@@ -2555,7 +2545,7 @@
 							   "Couldn't fdopen(), error: %d\n", errno);
 				}
 			}
-#endif
+
 			if(!fp) {
 				g_free(*fpath);
 				*fpath = NULL;