Undelete support for cRecordings

Message ID 200710111755.17395.mhahn@reel-multimedia.com
State New
Headers

Commit Message

Markus Hahn Oct. 11, 2007, 3:55 p.m. UTC
  Hi there, 

I improved extrec-plugin with  undelete functionality. 
The origin undelete seem so slow and overfeatured. 

@ KLS could  implenent this little API enhancement to vdr-core? 
Thanks 
there is also set default copy constr to private for save.  

regards Markus
  

Patch

Gemeinsame Unterverzeichnisse: vdr-1.5.9/libsi und vdr-1.5.9.1/libsi.
Gemeinsame Unterverzeichnisse: vdr-1.5.9/PLUGINS und vdr-1.5.9.1/PLUGINS.
Gemeinsame Unterverzeichnisse: vdr-1.5.9/po und vdr-1.5.9.1/po.
diff -Nu vdr-1.5.9/recording.c vdr-1.5.9.1/recording.c
--- vdr-1.5.9/recording.c	2007-06-17 15:10:12.000000000 +0200
+++ vdr-1.5.9.1/recording.c	2007-10-11 17:39:39.335047054 +0200
@@ -783,6 +783,34 @@ 
   return true;
 }
 
+bool cRecording::Undelete(void)
+{
+    printf ("\033[0;41m %s \033[0m\n", __PRETTY_FUNCTION__);
+    bool result = true;
+    char *NewName = strdup(FileName());
+    char *ext = strrchr(NewName, '.');
+    if (ext && strcmp(ext, DELEXT) == 0) {
+        strncpy(ext, RECEXT, strlen(ext));
+          printf ("\033[0;44m new FileName [%s] ... \nold FileName [%s]  \033[0m\n", NewName, FileName());
+        if (access(NewName, F_OK) == 0) {
+            // the new name already exists, so let's remove that one first:
+            esyslog("undelete  recording '%s'", NewName);
+            //Rename(NewName);
+        }
+        else { // 
+            isyslog("undeleting recording '%s'", FileName());
+            if (access(FileName(), F_OK) == 0)
+                result = RenameVideoFile(FileName(), NewName);
+            else {
+                isyslog("recording '%s' vanished", FileName());
+                result = false; // well, we were going to delete it, anyway
+            }
+        }
+    }
+    free(NewName);
+    return result;
+}
+
 bool cRecording::Delete(void)
 {
   bool result = true;
diff -Nu vdr-1.5.9/recording.h vdr-1.5.9.1/recording.h
--- vdr-1.5.9/recording.h	2007-06-17 14:53:05.000000000 +0200
+++ vdr-1.5.9.1/recording.h	2007-10-11 17:40:16.357156823 +0200
@@ -75,6 +75,7 @@ 
   static char *StripEpisodeName(char *s);
   char *SortName(void) const;
   int GetResume(void) const;
+  cRecording(const cRecording& obj);
 public:
   time_t start;
   int priority;
@@ -100,6 +101,10 @@ 
   bool Remove(void);
        // Actually removes the file from the disk
        // Returns false in case of error
+  bool Undelete(void);
+       // Changes the file name so that it will be visible in the "Recordings" menu again and 
+       // not catched by cRemoveDeletedRecordingsThread.
+       // Returns false in case of error
   };
 
 class cRecordings : public cList<cRecording>, public cThread {
Gemeinsame Unterverzeichnisse: vdr-1.5.9/symbols und vdr-1.5.9.1/symbols.