diff src/blist.c @ 10414:26eac2362c32

[gaim-migrate @ 11664] I'm starting to feel better. Little change here, little change there. Mostly I added a function gaim_util_write_xml_file to be used to write our config files. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 25 Dec 2004 18:33:27 +0000
parents aab0c9508318
children 3232e1a33899
line wrap: on
line diff
--- a/src/blist.c	Fri Dec 24 16:45:33 2004 +0000
+++ b/src/blist.c	Sat Dec 25 18:33:27 2004 +0000
@@ -2389,20 +2389,16 @@
 	char *filename;
 	char *filename_real;
 
-	if (!user_dir)
-		return;
+	g_return_if_fail(user_dir != NULL);
 
 	if (!blist_safe_to_write) {
-		gaim_debug(GAIM_DEBUG_WARNING, "blist save",
+		gaim_debug_warning("blist save",
 				   "AHH!! Tried to write the blist before we read it!\n");
 		return;
 	}
 
-	file = fopen(user_dir, "r");
-	if (!file)
+	if (!g_file_test(user_dir, G_FILE_TEST_IS_DIR))
 		mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR);
-	else
-		fclose(file);
 
 	filename = g_build_filename(user_dir, "blist.xml.save", NULL);
 
@@ -2411,8 +2407,7 @@
 		fclose(file);
 		chmod(filename, S_IRUSR | S_IWUSR);
 	} else {
-		gaim_debug(GAIM_DEBUG_ERROR, "blist save", "Unable to write %s\n",
-				   filename);
+		gaim_debug_error("blist", "Unable to write %s\n", filename);
 		g_free(filename);
 		return;
 	}
@@ -2427,7 +2422,7 @@
 	filename_real = g_build_filename(user_dir, "blist.xml", NULL);
 
 	if (rename(filename, filename_real) < 0)
-		gaim_debug(GAIM_DEBUG_ERROR, "blist save",
+		gaim_debug_error("blist",
 				   "Error renaming %s to %s\n", filename, filename_real);
 
 	g_free(filename);