summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2001-09-16 08:57:58 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2001-09-16 08:57:58 +0200
commit6ceefaf85f1866e15a90b961cdc589a4fc38b3ae (patch)
tree2a8a114ab8f661b54986002398dca3db5f0e6b6a /tools.c
parent9be288dbb41880b52ae5a3afb44dd082a045541b (diff)
downloadvdr-6ceefaf85f1866e15a90b961cdc589a4fc38b3ae.tar.gz
vdr-6ceefaf85f1866e15a90b961cdc589a4fc38b3ae.tar.bz2
Better error handling when writing configuration files
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/tools.c b/tools.c
index 0adf03e2..d6b65e55 100644
--- a/tools.c
+++ b/tools.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 1.44 2001/09/14 14:35:37 kls Exp $
+ * $Id: tools.c 1.45 2001/09/15 15:41:16 kls Exp $
*/
#define _GNU_SOURCE
@@ -554,13 +554,27 @@ bool cSafeFile::Open(void)
return f != NULL;
}
-void cSafeFile::Close(void)
+bool cSafeFile::Close(void)
{
+ bool result = true;
if (f) {
- fclose(f);
+ if (ferror(f) != 0) {
+ LOG_ERROR_STR(tempName);
+ result = false;
+ }
+ if (fclose(f) < 0) {
+ LOG_ERROR_STR(tempName);
+ result = false;
+ }
f = NULL;
- rename(tempName, fileName);
+ if (result && rename(tempName, fileName) < 0) {
+ LOG_ERROR_STR(fileName);
+ result = false;
+ }
}
+ else
+ result = false;
+ return result;
}
// --- cListObject -----------------------------------------------------------