summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/tools.c b/tools.c
index f51bc85..d6b65e5 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.43 2001/08/26 15:45:41 kls Exp $
+ * $Id: tools.c 1.45 2001/09/15 15:41:16 kls Exp $
*/
#define _GNU_SOURCE
@@ -21,8 +21,6 @@
#include <unistd.h>
#include "i18n.h"
-#define MaxBuffer 1000
-
int SysLogLevel = 3;
ssize_t safe_read(int filedes, void *buffer, size_t size)
@@ -56,7 +54,7 @@ void writechar(int filedes, char c)
char *readline(FILE *f)
{
- static char buffer[MaxBuffer];
+ static char buffer[MAXPARSEBUFFER];
if (fgets(buffer, sizeof(buffer), f) > 0) {
int l = strlen(buffer) - 1;
if (l >= 0 && buffer[l] == '\n')
@@ -556,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 -----------------------------------------------------------