diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2001-02-11 11:04:41 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2001-02-11 11:04:41 +0100 |
commit | 535e755278ef51b923a71299204ec86da4229d02 (patch) | |
tree | ae4a8678bb0d9c83d4be44e39ee43070f1e97aa7 /recording.c | |
parent | 7a92a259546000c367042e4c901fc4789f2225cb (diff) | |
download | vdr-535e755278ef51b923a71299204ec86da4229d02.tar.gz vdr-535e755278ef51b923a71299204ec86da4229d02.tar.bz2 |
Implemented 'Rewind' in the 'Recordings' menu
Diffstat (limited to 'recording.c')
-rw-r--r-- | recording.c | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/recording.c b/recording.c index dd364638..72b3135f 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.25 2001/02/04 12:36:32 kls Exp $ + * $Id: recording.c 1.26 2001/02/11 10:47:31 kls Exp $ */ #define _GNU_SOURCE @@ -15,7 +15,6 @@ #include <string.h> #include <sys/stat.h> #include <unistd.h> -#include "dvbapi.h" #include "interface.h" #include "tools.h" #include "videodir.h" @@ -25,6 +24,7 @@ #define DATAFORMAT "%4d-%02d-%02d.%02d:%02d.%02d.%02d" RECEXT #define NAMEFORMAT "%s/%s/" DATAFORMAT +#define RESUMEFILESUFFIX "/resume.vdr" #define SUMMARYFILESUFFIX "/summary.vdr" #define MARKSFILESUFFIX "/marks.vdr" @@ -109,6 +109,64 @@ void AssertFreeDiskSpace(void) } } +// --- cResumeFile ------------------------------------------------------------ + +cResumeFile::cResumeFile(const char *FileName) +{ + fileName = new char[strlen(FileName) + strlen(RESUMEFILESUFFIX) + 1]; + if (fileName) { + strcpy(fileName, FileName); + strcat(fileName, RESUMEFILESUFFIX); + } + else + esyslog(LOG_ERR, "ERROR: can't allocate memory for resume file name"); +} + +cResumeFile::~cResumeFile() +{ + delete fileName; +} + +int cResumeFile::Read(void) +{ + int resume = -1; + if (fileName) { + int f = open(fileName, O_RDONLY); + if (f >= 0) { + if (read(f, &resume, sizeof(resume)) != sizeof(resume)) { + resume = -1; + LOG_ERROR_STR(fileName); + } + close(f); + } + else if (errno != ENOENT) + LOG_ERROR_STR(fileName); + } + return resume; +} + +bool cResumeFile::Save(int Index) +{ + if (fileName) { + int f = open(fileName, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP); + if (f >= 0) { + if (write(f, &Index, sizeof(Index)) != sizeof(Index)) + LOG_ERROR_STR(fileName); + close(f); + return true; + } + } + return false; +} + +void cResumeFile::Delete(void) +{ + if (fileName) { + if (remove(fileName) < 0 && errno != ENOENT) + LOG_ERROR_STR(fileName); + } +} + // --- cRecording ------------------------------------------------------------ cRecording::cRecording(cTimer *Timer) |