summaryrefslogtreecommitdiff
path: root/libs/fsScan/src/LegacyVdrRecording.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/fsScan/src/LegacyVdrRecording.cc')
-rw-r--r--libs/fsScan/src/LegacyVdrRecording.cc83
1 files changed, 48 insertions, 35 deletions
diff --git a/libs/fsScan/src/LegacyVdrRecording.cc b/libs/fsScan/src/LegacyVdrRecording.cc
index 29bebe7..731d0f3 100644
--- a/libs/fsScan/src/LegacyVdrRecording.cc
+++ b/libs/fsScan/src/LegacyVdrRecording.cc
@@ -1,36 +1,47 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: LegacyVdrRecording.cc
* Created: 3. Juli 2012, 08
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: libfsScan: mediatypes and filesystem scanning
- *
+ *
* CMP - compound media player
- *
+ *
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
- *
+ *
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
+ *
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
+ *
* --------------------------------------------------------------
*/
#include <LegacyVdrRecording.h>
+#include <StringBuilder.h>
+#include <File.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
-#define FILE_MASK "/%03d.vdr"
-cLegacyVdrRecording::cLegacyVdrRecording(const char *Name, const char *Logical, const char *Path)
- : cAbstractMultiFileMovie(Name, Logical, Path, "video/mpeg", LegacyVdrRecording)
+#define FILE_MASK "%03d.vdr"
+
+cLegacyVdrRecording::cLegacyVdrRecording(const cFile &File)
+ : cAbstractMultiFileMovie(File, "video/mpeg", LegacyVdrRecording)
{
+ cStringBuilder sb;
+ cFile *parent = File.Parent();
+
+ sb.Append(parent->Name());
+ sb.Append(" (").Append(File.Name()).Append(")");
+ delete parent;
+ SetName(sb.toString());
+ bufSize = 8;
}
cLegacyVdrRecording::~cLegacyVdrRecording()
@@ -39,53 +50,55 @@ cLegacyVdrRecording::~cLegacyVdrRecording()
void cLegacyVdrRecording::Refresh(void)
{
- struct stat stBuf;
size_t total = 0;
- time_t lastMod = 0;
+ cFile *tmp;
- if (!fileNameBuf) {
- if (!(fileNameBuf = (char *)malloc(strlen(RealPath()) + 10))) {
- //TODO: some error message?
- return;
- }
- strcpy(fileNameBuf, RealPath());
- }
+ if (!checkBuffer()) return;
movieFiles = 0;
-
for (int fileNo = 1;; ++fileNo) {
- sprintf(fileNameBuf + strlen(RealPath()), FILE_MASK, fileNo);
- if (stat(fileNameBuf, &stBuf) < 0) {
+ sprintf(buf, FILE_MASK, fileNo);
+ tmp = new cFile(KeyPath(), buf);
+
+ if (!tmp || !tmp->Exists()) {
movieFiles = fileNo - 1;
+ delete tmp;
break;
}
- total += stBuf.st_size;
- if (stBuf.st_mtime > lastMod) lastMod = stBuf.st_mtime;
+ total += tmp->Size();
+ delete tmp;
}
SetSize(total);
- SetLastModified(lastMod);
}
const char *cLegacyVdrRecording::FirstFile(void)
{
- if (!fileNameBuf) {
- if (!(fileNameBuf = (char *)malloc(strlen(RealPath()) + 10))) {
- //TODO: some error message?
- return NULL;
- }
- strcpy(fileNameBuf, RealPath());
- }
+ if (!checkBuffer()) return NULL;
curFileNo = 1;
- sprintf(fileNameBuf + strlen(RealPath()), FILE_MASK, curFileNo);
+ sprintf(buf, FILE_MASK, curFileNo);
+ cFile *tmp = new cFile(KeyPath(), buf);
+ const char *rv = NULL;
- return fileNameBuf;
+ if (tmp) {
+ rv = tmp->AbsolutePath();
+ delete tmp;
+ }
+ return rv;
}
const char *cLegacyVdrRecording::NextFile(void)
{
if (++curFileNo < movieFiles) {
- sprintf(fileNameBuf + strlen(RealPath()), FILE_MASK, curFileNo);
+ if (!checkBuffer()) return NULL;
+ sprintf(buf, FILE_MASK, curFileNo);
+ cFile *tmp = new cFile(KeyPath(), buf);
+ const char *rv = NULL;
- return fileNameBuf;
+ if (tmp) {
+ rv = tmp->AbsolutePath();
+ delete tmp;
+
+ return rv;
+ }
}
return NULL;
}