summaryrefslogtreecommitdiff
path: root/recording.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2020-12-26 15:49:01 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2020-12-26 15:49:01 +0100
commit2b3556b460665d9a4036b1623e7e7ff5ff6d37d8 (patch)
treebee99e68a196ba076440ad6516b5a0149996b6f2 /recording.c
parentd2e0087c4e13b2acbecc4bafb3cb2ab656c95339 (diff)
downloadvdr-2b3556b460665d9a4036b1623e7e7ff5ff6d37d8.tar.gz
vdr-2b3556b460665d9a4036b1623e7e7ff5ff6d37d8.tar.bz2
Implemented "Pattern Timers"2.5.1
Diffstat (limited to 'recording.c')
-rw-r--r--recording.c70
1 files changed, 69 insertions, 1 deletions
diff --git a/recording.c b/recording.c
index 6bfbcff1..17467e36 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 4.29 2020/10/30 16:08:29 kls Exp $
+ * $Id: recording.c 5.1 2020/12/26 15:49:01 kls Exp $
*/
#include "recording.h"
@@ -3050,6 +3050,74 @@ cUnbufferedFile *cFileName::NextFile(void)
return SetOffset(fileNumber + 1);
}
+// --- cDoneRecordings -------------------------------------------------------
+
+cDoneRecordings DoneRecordingsPattern;
+
+bool cDoneRecordings::Load(const char *FileName)
+{
+ fileName = FileName;
+ if (*fileName && access(fileName, F_OK) == 0) {
+ isyslog("loading %s", *fileName);
+ FILE *f = fopen(fileName, "r");
+ if (f) {
+ char *s;
+ cReadLine ReadLine;
+ while ((s = ReadLine.Read(f)) != NULL)
+ Add(s);
+ fclose(f);
+ }
+ else {
+ LOG_ERROR_STR(*fileName);
+ return false;
+ }
+ }
+ return true;
+}
+
+bool cDoneRecordings::Save(void) const
+{
+ bool result = true;
+ cSafeFile f(fileName);
+ if (f.Open()) {
+ for (int i = 0; i < doneRecordings.Size(); i++) {
+ if (fputs(doneRecordings[i], f) == EOF || fputc('\n', f) == EOF) {
+ result = false;
+ break;
+ }
+ }
+ if (!f.Close())
+ result = false;
+ }
+ else
+ result = false;
+ return result;
+}
+
+void cDoneRecordings::Add(const char *Title)
+{
+ doneRecordings.Append(strdup(Title));
+}
+
+void cDoneRecordings::Append(const char *Title)
+{
+ if (!Contains(Title)) {
+ Add(Title);
+ if (FILE *f = fopen(fileName, "a")) {
+ fputs(Title, f);
+ fputc('\n', f);
+ fclose(f);
+ }
+ else
+ esyslog("ERROR: can't open '%s' for appending '%s'", *fileName, Title);
+ }
+}
+
+bool cDoneRecordings::Contains(const char *Title) const
+{
+ return doneRecordings.Find(Title) >= 0;
+}
+
// --- Index stuff -----------------------------------------------------------
cString IndexToHMSF(int Index, bool WithFrame, double FramesPerSecond)