changeset 21316:d0b16c09c2c4

Handle fwrite returning 0 in gg's "save my buddy list to a file" code, squashing a warning. (What's the point of this code given the various export/import plugins?)
author Will Thompson <will.thompson@collabora.co.uk>
date Sun, 11 Nov 2007 14:08:30 +0000
parents 8ae3eef4a27d
children 84925e6055bc
files libpurple/protocols/gg/gg.c
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/gg/gg.c	Sun Nov 11 13:03:31 2007 +0000
+++ b/libpurple/protocols/gg/gg.c	Sun Nov 11 14:08:30 2007 +0000
@@ -281,12 +281,22 @@
 		return;
 	}
 
-	fwrite(buddylist, sizeof(char), g_utf8_strlen(buddylist, -1), fh);
+	if (!fwrite(buddylist, sizeof(char), g_utf8_strlen(buddylist, -1), fh)) {
+		const gchar *err = g_strerror(errno);
+		gchar *title = g_strdup_printf(
+			_("Couldn't write buddylist to %s"), err);
+
+		purple_debug_error("gg", "Error writing %s: %s\n", file, err);
+		purple_notify_error(account, title, title, err);
+
+		g_free(title);
+	} else {
+		purple_notify_info(account, _("Save Buddylist..."),
+			 _("Buddylist saved successfully!"), NULL);
+	}
+
 	fclose(fh);
 	g_free(buddylist);
-
-	purple_notify_info(account, _("Save Buddylist..."),
-			 _("Buddylist saved successfully!"), NULL);
 }
 /* }}} */