summaryrefslogtreecommitdiff
path: root/command/marks.cpp
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2010-08-03 18:33:00 +0200
committerJochen Dolze <vdr@dolze.de>2010-08-03 18:33:00 +0200
commitfe701af3c1ebffea28edd89ec4fa97ea82c82cca (patch)
tree414987d2767164d7900ae1c68e8e91b2e4bbf9ca /command/marks.cpp
parent800fdfef53335279b99db9118f6b2972c957376b (diff)
downloadvdr-plugin-markad-fe701af3c1ebffea28edd89ec4fa97ea82c82cca.tar.gz
vdr-plugin-markad-fe701af3c1ebffea28edd89ec4fa97ea82c82cca.tar.bz2
Index repair now done by markad instead of genindex - and for TS too!
Diffstat (limited to 'command/marks.cpp')
-rw-r--r--command/marks.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/command/marks.cpp b/command/marks.cpp
index 5cf8530..4afae07 100644
--- a/command/marks.cpp
+++ b/command/marks.cpp
@@ -44,6 +44,7 @@ clMark::~clMark()
clMarks::~clMarks()
{
DelAll();
+ if (indexfd!=-1) close(indexfd);
}
int clMarks::Count(int Type)
@@ -307,6 +308,60 @@ char *clMarks::IndexToHMSF(int Index, double FramesPerSecond)
return buf;
}
+void clMarks::WriteIndex(const char *Directory, bool isTS, uint64_t Offset,
+ int FrameType, int Number)
+{
+ if (indexfd==-1)
+ {
+ char *ipath=NULL;
+ if (asprintf(&ipath,"%s/index%s.generated",Directory,isTS ? "" : ".vdr")==-1) return;
+ indexfd=open(ipath,O_WRONLY|O_CREAT|O_TRUNC,0644);
+ free(ipath);
+ if (indexfd==-1) return;
+ }
+ if (isTS)
+ {
+ struct tIndexTS IndexTS;
+ IndexTS.offset=Offset;
+ IndexTS.reserved=0;
+ IndexTS.independent=(FrameType==1);
+ IndexTS.number=(uint16_t) Number;
+ write(indexfd,&IndexTS,sizeof(IndexTS));
+ }
+ else
+ {
+ struct tIndexVDR IndexVDR;
+ IndexVDR.offset=(int) Offset;
+ IndexVDR.type=(unsigned char) FrameType;
+ IndexVDR.number=(unsigned char) Number;
+ IndexVDR.reserved=0;
+ write(indexfd,&IndexVDR,sizeof(IndexVDR));
+ }
+}
+
+void clMarks::CloseIndex(const char *Directory, bool isTS)
+{
+ if (indexfd!=-1)
+ {
+ if (getuid()==0 || geteuid()!=0)
+ {
+ // if we are root, set fileowner to owner of 001.vdr/00001.ts file
+ char *spath=NULL;
+ if (asprintf(&spath,"%s/%s",Directory,isTS ? "00001.ts" : "001.vdr")!=-1)
+ {
+ struct stat statbuf;
+ if (!stat(spath,&statbuf))
+ {
+ if (fchown(indexfd,statbuf.st_uid, statbuf.st_gid)) {};
+ }
+ free(spath);
+ }
+ }
+ close(indexfd);
+ }
+ indexfd=-1;
+}
+
bool clMarks::CheckIndex(const char *Directory, bool isTS, bool *IndexError)
{
if (!IndexError) return false;