summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2001-01-13 15:36:31 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2001-01-13 15:36:31 +0100
commit297e727a59b2e08f8c414739325f8df390b567c4 (patch)
tree0eb697cc5be0968b3fbcc7151f87e2fc5b8ac647 /config.c
parentba2c25d1835dae0030b12e35b814c2b0ab9406fb (diff)
downloadvdr-297e727a59b2e08f8c414739325f8df390b567c4.tar.gz
vdr-297e727a59b2e08f8c414739325f8df390b567c4.tar.bz2
Implemented safe writing of config files
Diffstat (limited to 'config.c')
-rw-r--r--config.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/config.c b/config.c
index 781900d7..a20c801b 100644
--- a/config.c
+++ b/config.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: config.c 1.37 2001/01/13 12:36:32 kls Exp $
+ * $Id: config.c 1.38 2001/01/13 15:36:31 kls Exp $
*/
#include "config.h"
@@ -119,10 +119,9 @@ bool cKeys::Load(const char *FileName)
bool cKeys::Save(void)
{
- //TODO make backup copies???
bool result = true;
- FILE *f = fopen(fileName, "w");
- if (f) {
+ cSafeFile f(fileName);
+ if (f.Open()) {
if (fprintf(f, "Code\t%c\nAddress\t%04X\n", code, address) > 0) {
for (tKey *k = keys; k->type != kNone; k++) {
if (fprintf(f, "%s\t%08X\n", k->name, k->code) <= 0) {
@@ -133,7 +132,7 @@ bool cKeys::Save(void)
}
else
result = false;
- fclose(f);
+ f.Close();
}
else
result = false;
@@ -782,8 +781,8 @@ bool cSetup::Save(const char *FileName)
if (!FileName)
FileName = fileName;
if (FileName) {
- FILE *f = fopen(FileName, "w");
- if (f) {
+ cSafeFile f(FileName);
+ if (f.Open()) {
fprintf(f, "# VDR Setup\n");
fprintf(f, "OSDLanguage = %d\n", OSDLanguage);
fprintf(f, "PrimaryDVB = %d\n", PrimaryDVB);
@@ -796,7 +795,7 @@ bool cSetup::Save(const char *FileName)
fprintf(f, "MarginStart = %d\n", MarginStart);
fprintf(f, "MarginStop = %d\n", MarginStop);
fprintf(f, "EPGScanTimeout = %d\n", EPGScanTimeout);
- fclose(f);
+ f.Close();
isyslog(LOG_INFO, "saved setup to %s", FileName);
return true;
}