summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY1
-rw-r--r--recording.c12
-rw-r--r--recording.h4
-rw-r--r--tools.c20
-rw-r--r--tools.h3
-rw-r--r--vdr.c27
6 files changed, 51 insertions, 16 deletions
diff --git a/HISTORY b/HISTORY
index 5a5e43a6..f95ac51f 100644
--- a/HISTORY
+++ b/HISTORY
@@ -105,3 +105,4 @@ Video Disk Recorder Revision History
- When scrolling through a list it now moves a full page up or down when the
cursor reaches the top or bottom of the menu (thanks to Heino Goldenstein!).
- Added missing '#include <sys/stat.h>' to recording.c.
+- The video directory can now be defined with the command line option -v.
diff --git a/recording.c b/recording.c
index 067ce68a..277b9114 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.13 2000/07/27 20:01:05 kls Exp $
+ * $Id: recording.c 1.14 2000/07/28 12:47:54 kls Exp $
*/
#define _GNU_SOURCE
@@ -32,14 +32,14 @@
#define DISKCHECKDELTA 300 // seconds between checks for free disk space
-const char *BaseDir = "/video";
+const char *VideoDirectory = "/video";
static bool LowDiskSpace(void)
{
//TODO Find a simpler way to determine the amount of free disk space!
bool result = true;
char *cmd = NULL;
- asprintf(&cmd, DFCMD, BaseDir);
+ asprintf(&cmd, DFCMD, VideoDirectory);
FILE *p = popen(cmd, "r");
if (p) {
char *s;
@@ -124,7 +124,7 @@ cRecording::cRecording(const char *FileName)
{
titleBuffer = NULL;
fileName = strdup(FileName);
- FileName += strlen(BaseDir) + 1;
+ FileName += strlen(VideoDirectory) + 1;
char *p = strrchr(FileName, '/');
name = NULL;
@@ -190,7 +190,7 @@ const char *cRecording::FileName(void)
{
if (!fileName) {
struct tm *t = localtime(&start);
- asprintf(&fileName, NAMEFORMAT, BaseDir, name, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, priority, lifetime);
+ asprintf(&fileName, NAMEFORMAT, VideoDirectory, name, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, priority, lifetime);
if (fileName)
strreplace(fileName, ' ', '_');
}
@@ -262,7 +262,7 @@ bool cRecordings::Load(bool Deleted)
Clear();
bool result = false;
char *cmd = NULL;
- asprintf(&cmd, FINDCMD, BaseDir, Deleted ? "*" DELEXT : "*" RECEXT);
+ asprintf(&cmd, FINDCMD, VideoDirectory, Deleted ? "*" DELEXT : "*" RECEXT);
FILE *p = popen(cmd, "r");
if (p) {
char *s;
diff --git a/recording.h b/recording.h
index e501af82..ae17cd3c 100644
--- a/recording.h
+++ b/recording.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: recording.h 1.7 2000/07/23 19:06:14 kls Exp $
+ * $Id: recording.h 1.8 2000/07/28 12:48:06 kls Exp $
*/
#ifndef __RECORDING_H
@@ -14,6 +14,8 @@
#include "config.h"
#include "tools.h"
+extern const char *VideoDirectory;
+
void AssertFreeDiskSpace(void);
class cRecording : public cListObject {
diff --git a/tools.c b/tools.c
index 998d91b3..88acd333 100644
--- a/tools.c
+++ b/tools.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 1.10 2000/07/23 13:16:54 kls Exp $
+ * $Id: tools.c 1.11 2000/07/28 13:22:10 kls Exp $
*/
#define _GNU_SOURCE
@@ -145,6 +145,24 @@ bool isnumber(const char *s)
return true;
}
+bool DirectoryOk(const char *DirName)
+{
+ struct stat ds;
+ if (stat(DirName, &ds) == 0) {
+ if (S_ISDIR(ds.st_mode)) {
+ if (access(DirName, R_OK | W_OK | X_OK) == 0)
+ return true;
+ else
+ esyslog(LOG_ERR, "ERROR: can't access %s", DirName);
+ }
+ else
+ esyslog(LOG_ERR, "ERROR: %s is not a directory", DirName);
+ }
+ else
+ LOG_ERROR_STR(DirName);
+ return false;
+}
+
bool MakeDirs(const char *FileName, bool IsDirectory)
{
bool result = true;
diff --git a/tools.h b/tools.h
index ecf42be6..dc22033d 100644
--- a/tools.h
+++ b/tools.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.h 1.10 2000/07/23 13:16:37 kls Exp $
+ * $Id: tools.h 1.11 2000/07/28 13:02:05 kls Exp $
*/
#ifndef __TOOLS_H
@@ -43,6 +43,7 @@ char *skipspace(char *s);
int time_ms(void);
void delay_ms(int ms);
bool isnumber(const char *s);
+bool DirectoryOk(const char *DirName);
bool MakeDirs(const char *FileName, bool IsDirectory = false);
bool RemoveFileOrDir(const char *FileName);
bool CheckProcess(pid_t pid);
diff --git a/vdr.c b/vdr.c
index 626e6dc0..36ddcb42 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
*
* The project's page is at http://www.cadsoft.de/people/kls/vdr
*
- * $Id: vdr.c 1.23 2000/07/23 15:36:43 kls Exp $
+ * $Id: vdr.c 1.24 2000/07/28 13:14:19 kls Exp $
*/
#include <getopt.h>
@@ -65,20 +65,24 @@ int main(int argc, char *argv[])
{ "daemon", no_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' },
{ "port", required_argument, NULL, 'p' },
+ { "video", required_argument, NULL, 'v' },
{ 0 }
};
int c;
int option_index = 0;
- while ((c = getopt_long(argc, argv, "dhp:", long_options, &option_index)) != -1) {
+ while ((c = getopt_long(argc, argv, "dhp:v:", long_options, &option_index)) != -1) {
switch (c) {
case 'd': DaemonMode = true; break;
case 'h': printf("Usage: vdr [OPTION]\n\n"
" -h, --help display this help and exit\n"
" -d, --daemon run in daemon mode\n"
- " -p PORT, --port=PORT use PORT for SVDRP ('0' turns off SVDRP)\n"
+ " -p PORT, --port=PORT use PORT for SVDRP (default: %d, '0' turns off SVDRP)\n"
+ " -v DIR, --video=DIR use DIR as video directory (default is %s)\n"
"\n"
- "Report bugs to <vdr-bugs@cadsoft.de>\n"
+ "Report bugs to <vdr-bugs@cadsoft.de>\n",
+ DEFAULTSVDRPPORT,
+ VideoDirectory
);
return 0;
break;
@@ -86,9 +90,11 @@ int main(int argc, char *argv[])
SVDRPport = strtol(optarg, NULL, 10);
else {
fprintf(stderr, "vdr: invalid port number: %s\n", optarg);
- return 1;
+ abort();
}
break;
+ case 'v': VideoDirectory = optarg;
+ break;
default: abort();
}
}
@@ -97,6 +103,13 @@ int main(int argc, char *argv[])
openlog("vdr", LOG_PID | LOG_CONS, LOG_USER);
+ // Check the video directory:
+
+ if (!DirectoryOk(VideoDirectory)) {
+ fprintf(stderr, "vdr: can't access video directory %s\n", VideoDirectory);
+ abort();
+ }
+
// Daemon mode:
if (DaemonMode) {
@@ -105,7 +118,7 @@ int main(int argc, char *argv[])
if (pid < 0) {
fprintf(stderr, "%s\n", strerror(errno));
esyslog(LOG_ERR, strerror(errno));
- return 1;
+ abort();
}
if (pid != 0)
return 0; // initial program immediately returns
@@ -122,7 +135,7 @@ int main(int argc, char *argv[])
// DVB interfaces:
if (!cDvbApi::Init())
- return 1;
+ abort();
// Configuration data: