summaryrefslogtreecommitdiff
path: root/recording.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2007-10-14 10:23:19 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2007-10-14 10:23:19 +0200
commit7780e3664a5d76c84b5d1971e833ba8cc27c0f82 (patch)
treedc1863f964aa590b630bd25210a336c6ba8c1164 /recording.c
parentc6ef96a6aea24e64c70792d7eec9e5f9cc89821a (diff)
downloadvdr-7780e3664a5d76c84b5d1971e833ba8cc27c0f82.tar.gz
vdr-7780e3664a5d76c84b5d1971e833ba8cc27c0f82.tar.bz2
Added cRecording::Undelete()
Diffstat (limited to 'recording.c')
-rw-r--r--recording.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/recording.c b/recording.c
index 7886adaa..51846114 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.155 2007/10/12 14:48:20 kls Exp $
+ * $Id: recording.c 1.156 2007/10/14 10:21:54 kls Exp $
*/
#include "recording.h"
@@ -829,6 +829,32 @@ bool cRecording::Remove(void)
return RemoveVideoFile(FileName());
}
+bool cRecording::Undelete(void)
+{
+ bool result = true;
+ char *NewName = strdup(FileName());
+ char *ext = strrchr(NewName, '.');
+ if (ext && strcmp(ext, DELEXT) == 0) {
+ strncpy(ext, RECEXT, strlen(ext));
+ if (access(NewName, F_OK) == 0) {
+ // the new name already exists, so let's not remove that one:
+ esyslog("ERROR: attempt to undelete '%s', while recording '%s' exists", FileName(), NewName);
+ result = false;
+ }
+ else {
+ isyslog("undeleting recording '%s'", FileName());
+ if (access(FileName(), F_OK) == 0)
+ result = RenameVideoFile(FileName(), NewName);
+ else {
+ isyslog("deleted recording '%s' vanished", FileName());
+ result = false;
+ }
+ }
+ }
+ free(NewName);
+ return result;
+}
+
void cRecording::ResetResume(void) const
{
resume = RESUME_NOT_INITIALIZED;