Minor mod to wd and hts settings to allow abs paths to be passed to hts_settings_load().

This commit is contained in:
Adam Sutton 2012-06-26 13:09:28 +01:00
parent dcbcf4fe35
commit 0b0012476d
2 changed files with 19 additions and 5 deletions

View 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;
}

View 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;
}