changeset 314:f538bddc22f4

Use secure save in comment_file_write().
author zas_
date Fri, 11 Apr 2008 17:11:14 +0000
parents a955b7fd626b
children d5a3bcc6a694
files src/bar_info.c
diffstat 1 files changed, 13 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/bar_info.c	Fri Apr 11 16:46:21 2008 +0000
+++ b/src/bar_info.c	Fri Apr 11 17:11:14 2008 +0000
@@ -18,6 +18,7 @@
 #include "cache.h"
 #include "filelist.h"
 #include "info.h"
+#include "secure_save.h"
 #include "utilops.h"
 #include "ui_bookmark.h"
 #include "ui_fileops.h"
@@ -51,31 +52,29 @@
 
 static gint comment_file_write(gchar *path, GList *keywords, const gchar *comment)
 {
-	FILE *f;
+	SecureSaveInfo *ssi;
 
-	f = fopen(path, "w");
-	if (!f) return FALSE;
+	ssi = secure_open(path);
+	if (!ssi) return FALSE;
 
-	fprintf(f, "#%s comment (%s)\n\n", GQ_APPNAME, VERSION);
+	secure_fprintf(ssi, "#%s comment (%s)\n\n", GQ_APPNAME, VERSION);
 
-	fprintf(f, "[keywords]\n");
-	while (keywords)
+	secure_fprintf(ssi, "[keywords]\n");
+	while (keywords && secsave_errno == SS_ERR_NONE)
 		{
 		const gchar *word = keywords->data;
 		keywords = keywords->next;
 
-		fprintf(f, "%s\n", word);
+		secure_fprintf(ssi, "%s\n", word);
 		}
-	fprintf(f, "\n");
+	secure_fputc(ssi, '\n');
 
-	fprintf(f, "[comment]\n");
-	fprintf(f, "%s\n", (comment) ? comment : "");
+	secure_fprintf(ssi, "[comment]\n");
+	secure_fprintf(ssi, "%s\n", (comment) ? comment : "");
 
-	fprintf(f, "#end\n");
+	secure_fprintf(ssi, "#end\n");
 
-	fclose(f);
-
-	return TRUE;
+	return (secure_close(ssi) == 0);
 }
 
 static gint comment_legacy_write(FileData *fd, GList *keywords, const gchar *comment)