pidgin: d6dcc1a4: Replace some old code using fwrite() wit...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Sat Nov 29 19:00:46 EST 2008


-----------------------------------------------------------------
Revision: d6dcc1a4c4c210ef92876374958ac4e4cb237c05
Ancestor: 9ba9fc8e618e033ab6a9245be2210194b6364e75
Author: rekkanoryo at pidgin.im
Date: 2008-11-29T23:35:12
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d6dcc1a4c4c210ef92876374958ac4e4cb237c05

Modified files:
        COPYRIGHT pidgin/gtkconv.c

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- COPYRIGHT	a41c71a2f3659276bd8534a1b1bee1a4d2a91a94
+++ COPYRIGHT	8cdadaee6daded144eeef5809d1396f8cfba62ee
@@ -436,6 +436,7 @@ Junichi Uekawa
 Brad Turcotte
 Kyle Turman
 Junichi Uekawa
+Eduardo P?rez Ureta
 Igor Vlasenko
 Istv?n V?radi
 Martijn van Beers
============================================================
--- pidgin/gtkconv.c	8d8e93dd5b09f0da539c88a2afc810a7dcb93389
+++ pidgin/gtkconv.c	bd8b7cd437c2521d890a1c0c534bc1ca7f4561e4
@@ -2759,26 +2759,16 @@ saveicon_writefile_cb(void *user_data, c
 {
 	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


More information about the Commits mailing list