summaryrefslogtreecommitdiff
path: root/recording.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2005-05-07 15:29:23 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2005-05-07 15:29:23 +0200
commit1f246351b1f3872edfaa73683fc6755dac1a6bf9 (patch)
tree6400544a62506071ec254b5d858b61de31db6449 /recording.c
parentf2bb5b34741910aa60b59079b146881eae4f1d00 (diff)
downloadvdr-1f246351b1f3872edfaa73683fc6755dac1a6bf9.tar.gz
vdr-1f246351b1f3872edfaa73683fc6755dac1a6bf9.tar.bz2
Recordings now avoid zero sized video data files
Diffstat (limited to 'recording.c')
-rw-r--r--recording.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/recording.c b/recording.c
index dde2ee38..ed74c462 100644
--- a/recording.c
+++ b/recording.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: recording.c 1.97 2005/05/06 14:00:23 kls Exp $
+ * $Id: recording.c 1.98 2005/05/07 15:25:15 kls Exp $
*/
#include "recording.h"
@@ -1124,8 +1124,21 @@ int cFileName::SetOffset(int Number, int Offset)
fileNumber = Number;
sprintf(pFileNumber, RECORDFILESUFFIX, fileNumber);
if (record) {
- if (access(fileName, F_OK) == 0) // file exists, let's try next suffix
- return SetOffset(Number + 1);
+ if (access(fileName, F_OK) == 0) {
+ // files exists, check if it has non-zero size
+ struct stat buf;
+ if (stat(fileName, &buf) == 0) {
+ if (buf.st_size != 0)
+ return SetOffset(Number + 1); // file exists and has non zero size, let's try next suffix
+ else {
+ // zero size file, remove it
+ dsyslog ("cFileName::SetOffset: removing zero-sized file %s\n", fileName);
+ unlink (fileName);
+ }
+ }
+ else
+ return SetOffset(Number + 1); // error with fstat - should not happen, just to be on the safe side
+ }
else if (errno != ENOENT) { // something serious has happened
LOG_ERROR_STR(fileName);
return -1;