]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Minor mod to wd and hts settings to allow abs paths to be passed to hts_settings_load().
authorAdam Sutton <dev@adamsutton.me.uk>
Tue, 26 Jun 2012 12:09:28 +0000 (13:09 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Mon, 30 Jul 2012 12:34:22 +0000 (13:34 +0100)
src/settings.c
support/dataroot/wd.c

index ca3c72701091803b6738063a93383f30c73857b6..c44e09e5b4d517406f76a758cd8c0d411cc2d3ad 100644 (file)
@@ -206,20 +206,24 @@ hts_settings_load_one(const char *filename)
 static int
 hts_settings_buildpath(char *dst, size_t dstsize, const char *fmt, va_list ap)
 {
+  char tmp[256];
   char *n = dst;
 
   if(settingspath == NULL)
      return -1;
-
-  snprintf(dst, dstsize, "%s/", settingspath);
-
-  vsnprintf(dst + strlen(dst), dstsize - strlen(dst), fmt, ap);
+  
+  vsnprintf(tmp, sizeof(tmp), fmt, ap);
+  if (*tmp != '/')
+    snprintf(dst, dstsize, "%s/%s", settingspath, tmp);
+  else
+    strncpy(dst, tmp, dstsize);
 
   while(*n) {
     if(*n == ':' || *n == '?' || *n == '*' || *n > 127 || *n < 32)
       *n = '_';
     n++;
   }
+  printf("hts_settings_buildpath(): %s => %s\n", fmt, dst);
   return 0;
 }
 
index 9b653eb2d35a55bf26c13ee24964178bb5ceb668..643695803a8a29875ca80936f6d39e07de445256 100644 (file)
@@ -1,4 +1,14 @@
+#include <string.h>
+#include <unistd.h>
+#include <assert.h>
+
 const char *tvheadend_dataroot(void)
 {
-  return "./";
+  static char cwd[256] = { 0 };
+  if (!*cwd) {
+    assert(getcwd(cwd, 254));
+    strcat(cwd, "/");
+  }
+   printf("cwd = %s\n", cwd);
+  return cwd;
 }