mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Reverted to 'find' instead of 'ftw()' to collect recordings (ftw() was much slower)
This commit is contained in:
parent
873286b7a3
commit
fe5809c4e3
@ -176,8 +176,5 @@ Lauri Pesonen <lauri.pesonen@firsthop.com>
|
|||||||
for avoiding linking in 'libncurses' if compiling without DEBUG_OSD=1 and
|
for avoiding linking in 'libncurses' if compiling without DEBUG_OSD=1 and
|
||||||
REMOTE=KBD
|
REMOTE=KBD
|
||||||
|
|
||||||
Emil Naepflein <Emil.Naepflein@philosys.de>
|
|
||||||
for his hint about the 'ftw()' library function
|
|
||||||
|
|
||||||
Sergei Haller <Sergei.Haller@math.uni-giessen.de>
|
Sergei Haller <Sergei.Haller@math.uni-giessen.de>
|
||||||
for fixing the LastActivity timestamp after a shutdown prompt
|
for fixing the LastActivity timestamp after a shutdown prompt
|
||||||
|
3
HISTORY
3
HISTORY
@ -900,9 +900,6 @@ Video Disk Recorder Revision History
|
|||||||
subdirectories for the recordings. This can be controlled through the
|
subdirectories for the recordings. This can be controlled through the
|
||||||
"RecordingDirs" parameter in the "Setup" menu.
|
"RecordingDirs" parameter in the "Setup" menu.
|
||||||
See "MANUAL/Replaying a Recording" for details.
|
See "MANUAL/Replaying a Recording" for details.
|
||||||
- Now using a call to the 'ftw()' library function instead of an external 'find'
|
|
||||||
command to collect the recordings (thanks to Emil Naepflein for his hint about
|
|
||||||
this function).
|
|
||||||
- Improved speed of setting the Help button texts.
|
- Improved speed of setting the Help button texts.
|
||||||
- Fixed handling file names that contain single quotes (') or dollar signs ($)
|
- Fixed handling file names that contain single quotes (') or dollar signs ($)
|
||||||
in the call to the shutdown command (option '-s') and the recording command
|
in the call to the shutdown command (option '-s') and the recording command
|
||||||
|
51
recording.c
51
recording.c
@ -4,13 +4,12 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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 "recording.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <ftw.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -33,6 +32,8 @@
|
|||||||
#define SUMMARYFILESUFFIX "/summary.vdr"
|
#define SUMMARYFILESUFFIX "/summary.vdr"
|
||||||
#define MARKSFILESUFFIX "/marks.vdr"
|
#define MARKSFILESUFFIX "/marks.vdr"
|
||||||
|
|
||||||
|
#define FINDCMD "find %s -follow -type d -name '%s' 2> /dev/null"
|
||||||
|
|
||||||
#define MINDISKSPACE 1024 // MB
|
#define MINDISKSPACE 1024 // MB
|
||||||
|
|
||||||
#define DELETEDLIFETIME 1 // hours after which a deleted recording will be actually removed
|
#define DELETEDLIFETIME 1 // hours after which a deleted recording will be actually removed
|
||||||
@ -484,39 +485,29 @@ bool cRecording::Remove(void)
|
|||||||
|
|
||||||
// --- cRecordings -----------------------------------------------------------
|
// --- 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)
|
bool cRecordings::Load(bool Deleted)
|
||||||
{
|
{
|
||||||
if (FilterRecordings)
|
|
||||||
return false; // because of the static Filter() function only _one_ call at a time is allowed!
|
|
||||||
Clear();
|
Clear();
|
||||||
bool result = true;
|
bool result = false;
|
||||||
FilterRecordings = this;
|
char *cmd = NULL;
|
||||||
FilterSuffix = Deleted ? DELEXT : RECEXT;
|
asprintf(&cmd, FINDCMD, VideoDirectory, Deleted ? "*" DELEXT : "*" RECEXT);
|
||||||
if (ftw(VideoDirectory, Filter, 10) < 0) {
|
FILE *p = popen(cmd, "r");
|
||||||
LOG_ERROR;
|
if (p) {
|
||||||
result = errno != ESTALE; // apparently stale NFS file handles are not really a problem?
|
char *s;
|
||||||
|
while ((s = readline(p)) != NULL) {
|
||||||
|
cRecording *r = new cRecording(s);
|
||||||
|
if (r->Name())
|
||||||
|
Add(r);
|
||||||
|
else
|
||||||
|
delete r;
|
||||||
}
|
}
|
||||||
|
pclose(p);
|
||||||
Sort();
|
Sort();
|
||||||
result = result && Count() > 0;
|
result = Count() > 0;
|
||||||
FilterRecordings = NULL;
|
}
|
||||||
FilterSuffix = NULL;
|
else
|
||||||
|
Interface->Error("Error while opening pipe!");
|
||||||
|
delete cmd;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user