Mercurial > geeqie.yaz
comparison src/bar_info.c @ 314:f538bddc22f4
Use secure save in comment_file_write().
author | zas_ |
---|---|
date | Fri, 11 Apr 2008 17:11:14 +0000 |
parents | d1f74154463e |
children | b16b9b8979e5 |
comparison
equal
deleted
inserted
replaced
313:a955b7fd626b | 314:f538bddc22f4 |
---|---|
16 #include "bar_info.h" | 16 #include "bar_info.h" |
17 | 17 |
18 #include "cache.h" | 18 #include "cache.h" |
19 #include "filelist.h" | 19 #include "filelist.h" |
20 #include "info.h" | 20 #include "info.h" |
21 #include "secure_save.h" | |
21 #include "utilops.h" | 22 #include "utilops.h" |
22 #include "ui_bookmark.h" | 23 #include "ui_bookmark.h" |
23 #include "ui_fileops.h" | 24 #include "ui_fileops.h" |
24 #include "ui_misc.h" | 25 #include "ui_misc.h" |
25 #include "ui_utildlg.h" | 26 #include "ui_utildlg.h" |
49 *------------------------------------------------------------------- | 50 *------------------------------------------------------------------- |
50 */ | 51 */ |
51 | 52 |
52 static gint comment_file_write(gchar *path, GList *keywords, const gchar *comment) | 53 static gint comment_file_write(gchar *path, GList *keywords, const gchar *comment) |
53 { | 54 { |
54 FILE *f; | 55 SecureSaveInfo *ssi; |
55 | 56 |
56 f = fopen(path, "w"); | 57 ssi = secure_open(path); |
57 if (!f) return FALSE; | 58 if (!ssi) return FALSE; |
58 | 59 |
59 fprintf(f, "#%s comment (%s)\n\n", GQ_APPNAME, VERSION); | 60 secure_fprintf(ssi, "#%s comment (%s)\n\n", GQ_APPNAME, VERSION); |
60 | 61 |
61 fprintf(f, "[keywords]\n"); | 62 secure_fprintf(ssi, "[keywords]\n"); |
62 while (keywords) | 63 while (keywords && secsave_errno == SS_ERR_NONE) |
63 { | 64 { |
64 const gchar *word = keywords->data; | 65 const gchar *word = keywords->data; |
65 keywords = keywords->next; | 66 keywords = keywords->next; |
66 | 67 |
67 fprintf(f, "%s\n", word); | 68 secure_fprintf(ssi, "%s\n", word); |
68 } | 69 } |
69 fprintf(f, "\n"); | 70 secure_fputc(ssi, '\n'); |
70 | 71 |
71 fprintf(f, "[comment]\n"); | 72 secure_fprintf(ssi, "[comment]\n"); |
72 fprintf(f, "%s\n", (comment) ? comment : ""); | 73 secure_fprintf(ssi, "%s\n", (comment) ? comment : ""); |
73 | 74 |
74 fprintf(f, "#end\n"); | 75 secure_fprintf(ssi, "#end\n"); |
75 | 76 |
76 fclose(f); | 77 return (secure_close(ssi) == 0); |
77 | |
78 return TRUE; | |
79 } | 78 } |
80 | 79 |
81 static gint comment_legacy_write(FileData *fd, GList *keywords, const gchar *comment) | 80 static gint comment_legacy_write(FileData *fd, GList *keywords, const gchar *comment) |
82 { | 81 { |
83 gchar *comment_path; | 82 gchar *comment_path; |