Mercurial > pidgin
comparison src/list.c @ 4891:cfa045006bec
[gaim-migrate @ 5221]
this saves the blist.xml file to an alternate name, and then moves it, that
way we don't lose your precious buddies if gaim crashes.
Of course, if gaim were to crash, it wouldn't be gaim's fault, it would be
the fault of some external force. This is because gaim is perfect, and
Sean is perfect. Yeah.
This should be done for .gaimrc too, but i'm too tired to do that right now.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Tue, 25 Mar 2003 06:35:45 +0000 |
parents | 3bc5a65728fb |
children | a1551892049c |
comparison
equal
deleted
inserted
replaced
4890:89cb14edf8cf | 4891:cfa045006bec |
---|---|
1209 | 1209 |
1210 void gaim_blist_save() { | 1210 void gaim_blist_save() { |
1211 FILE *file; | 1211 FILE *file; |
1212 char *user_dir = gaim_user_dir(); | 1212 char *user_dir = gaim_user_dir(); |
1213 char *filename; | 1213 char *filename; |
1214 char *filename_real; | |
1214 | 1215 |
1215 if(!user_dir) | 1216 if(!user_dir) |
1216 return; | 1217 return; |
1217 if(!blist_safe_to_write) { | 1218 if(!blist_safe_to_write) { |
1218 debug_printf("AHH!! tried to write the blist before we read it!\n"); | 1219 debug_printf("AHH!! tried to write the blist before we read it!\n"); |
1223 if(!file) | 1224 if(!file) |
1224 mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR); | 1225 mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR); |
1225 else | 1226 else |
1226 fclose(file); | 1227 fclose(file); |
1227 | 1228 |
1228 filename = g_build_filename(user_dir, "blist.xml", NULL); | 1229 filename = g_build_filename(user_dir, "blist.xml.save", NULL); |
1229 | 1230 |
1230 if((file = fopen(filename, "w"))) { | 1231 if((file = fopen(filename, "w"))) { |
1231 gaim_blist_write(file, NULL); | 1232 gaim_blist_write(file, NULL); |
1232 fclose(file); | 1233 fclose(file); |
1233 chmod(filename, S_IRUSR | S_IWUSR); | 1234 chmod(filename, S_IRUSR | S_IWUSR); |
1234 } else { | 1235 } else { |
1235 debug_printf("unable to write %s\n", filename); | 1236 debug_printf("unable to write %s\n", filename); |
1236 } | 1237 } |
1237 | 1238 |
1239 filename_real = g_build_filename(user_dir, "blist.xml", NULL); | |
1240 | |
1241 if(rename(filename, filename_real) < 0) | |
1242 debug_printf("error renaming %s to %s\n", filename, filename_real); | |
1243 | |
1244 | |
1238 g_free(filename); | 1245 g_free(filename); |
1246 g_free(filename_real); | |
1239 } | 1247 } |
1240 | 1248 |
1241 gboolean gaim_privacy_permit_add(struct gaim_account *account, const char *who) { | 1249 gboolean gaim_privacy_permit_add(struct gaim_account *account, const char *who) { |
1242 GSList *d = account->permit; | 1250 GSList *d = account->permit; |
1243 char *n = g_strdup(normalize(who)); | 1251 char *n = g_strdup(normalize(who)); |