changeset 24513:cff5d920b87f

Replace some old code using fwrite() with a call to purple_util_write_data_to_file_absolute(), simplifying some code and improving readability. Fixes #3525.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Sat, 29 Nov 2008 23:35:12 +0000
parents e1c38e93d5c3
children 6b9552b09de0
files COPYRIGHT pidgin/gtkconv.c
diffstat 2 files changed, 3 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Sat Nov 29 19:53:05 2008 +0000
+++ b/COPYRIGHT	Sat Nov 29 23:35:12 2008 +0000
@@ -436,6 +436,7 @@
 Brad Turcotte
 Kyle Turman
 Junichi Uekawa
+Eduardo Pérez Ureta
 Igor Vlasenko
 István Váradi
 Martijn van Beers
--- a/pidgin/gtkconv.c	Sat Nov 29 19:53:05 2008 +0000
+++ b/pidgin/gtkconv.c	Sat Nov 29 23:35:12 2008 +0000
@@ -2759,26 +2759,16 @@
 {
 	PidginConversation *gtkconv = (PidginConversation *)user_data;
 	PurpleConversation *conv = gtkconv->active_conv;
-	FILE *fp;
 	PurpleBuddyIcon *icon;
 	const void *data;
 	size_t len;
 
-	if ((fp = g_fopen(filename, "wb")) == NULL) {
-		purple_notify_error(gtkconv, NULL, _("Unable to open file."), NULL);
-		return;
-	}
-
 	icon = purple_conv_im_get_icon(PURPLE_CONV_IM(conv));
 	data = purple_buddy_icon_get_data(icon, &len);
 
-	if ((len <= 0) || (data == NULL) || (fwrite(data, 1, len, fp) != len)) {
+	if ((len <= 0) || (data == NULL) || !purple_util_write_data_to_file_absolute(filename, data, len)) {
 		purple_notify_error(gtkconv, NULL, _("Unable to save icon file to disk."), NULL);
-		fclose(fp);
-		g_unlink(filename);
-		return;
-	}
-	fclose(fp);
+	}
 }
 
 static void