summaryrefslogtreecommitdiff
path: root/recording.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-01-27 15:14:45 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2002-01-27 15:14:45 +0100
commitfe5809c4e3a909b07ad9d6da7ceaa81f9aea48b9 (patch)
treee73177cb46599dbe8ced7a75d299dd5819e69667 /recording.c
parent873286b7a3f0def09c63f81bb54e5c9d8b850fa8 (diff)
downloadvdr-fe5809c4e3a909b07ad9d6da7ceaa81f9aea48b9.tar.gz
vdr-fe5809c4e3a909b07ad9d6da7ceaa81f9aea48b9.tar.bz2
Reverted to 'find' instead of 'ftw()' to collect recordings (ftw() was much slower)
Diffstat (limited to 'recording.c')
-rw-r--r--recording.c53
1 files changed, 22 insertions, 31 deletions
diff --git a/recording.c b/recording.c
index 89c1ad92..acdf264c 100644
--- a/recording.c
+++ b/recording.c
@@ -4,13 +4,12 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: recording.c 1.47 2002/01/27 14:10:25 kls Exp $
+ * $Id: recording.c 1.48 2002/01/27 15:14:45 kls Exp $
*/
#include "recording.h"
#include <errno.h>
#include <fcntl.h>
-#include <ftw.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
@@ -33,6 +32,8 @@
#define SUMMARYFILESUFFIX "/summary.vdr"
#define MARKSFILESUFFIX "/marks.vdr"
+#define FINDCMD "find %s -follow -type d -name '%s' 2> /dev/null"
+
#define MINDISKSPACE 1024 // MB
#define DELETEDLIFETIME 1 // hours after which a deleted recording will be actually removed
@@ -484,39 +485,29 @@ bool cRecording::Remove(void)
// --- cRecordings -----------------------------------------------------------
-cRecordings *FilterRecordings = NULL;
-const char *FilterSuffix = NULL;
-
-static int Filter(const char *Name, const struct stat *Stat, int Status)
-{
- if (FilterRecordings && FilterSuffix) {
- if (Status == FTW_D) {
- if (endswith(Name, FilterSuffix)) {
- cRecording *r = new cRecording(Name);
- FilterRecordings->Add(r);
- }
- }
- return 0;
- }
- return 1;
-}
-
bool cRecordings::Load(bool Deleted)
{
- if (FilterRecordings)
- return false; // because of the static Filter() function only _one_ call at a time is allowed!
Clear();
- bool result = true;
- FilterRecordings = this;
- FilterSuffix = Deleted ? DELEXT : RECEXT;
- if (ftw(VideoDirectory, Filter, 10) < 0) {
- LOG_ERROR;
- result = errno != ESTALE; // apparently stale NFS file handles are not really a problem?
+ bool result = false;
+ char *cmd = NULL;
+ asprintf(&cmd, FINDCMD, VideoDirectory, Deleted ? "*" DELEXT : "*" RECEXT);
+ FILE *p = popen(cmd, "r");
+ if (p) {
+ char *s;
+ while ((s = readline(p)) != NULL) {
+ cRecording *r = new cRecording(s);
+ if (r->Name())
+ Add(r);
+ else
+ delete r;
+ }
+ pclose(p);
+ Sort();
+ result = Count() > 0;
}
- Sort();
- result = result && Count() > 0;
- FilterRecordings = NULL;
- FilterSuffix = NULL;
+ else
+ Interface->Error("Error while opening pipe!");
+ delete cmd;
return result;
}