* Improve handling of the media_dir setting.
This commit is contained in:
parent
638c4a45d9
commit
7f3c4349f4
39
minidlna.c
39
minidlna.c
@ -447,30 +447,35 @@ init(int argc, char * * argv)
|
|||||||
break;
|
break;
|
||||||
case UPNPMEDIADIR:
|
case UPNPMEDIADIR:
|
||||||
type = ALL_MEDIA;
|
type = ALL_MEDIA;
|
||||||
char * myval = NULL;
|
path = ary_options[i].value;
|
||||||
switch( ary_options[i].value[0] )
|
if( *path && (path[1] == ',') && (access(path, F_OK) != 0) )
|
||||||
|
{
|
||||||
|
switch( *path )
|
||||||
{
|
{
|
||||||
case 'A':
|
case 'A':
|
||||||
case 'a':
|
case 'a':
|
||||||
if( ary_options[i].value[0] == 'A' || ary_options[i].value[0] == 'a' )
|
|
||||||
type = AUDIO_ONLY;
|
type = AUDIO_ONLY;
|
||||||
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
case 'v':
|
case 'v':
|
||||||
if( ary_options[i].value[0] == 'V' || ary_options[i].value[0] == 'v' )
|
|
||||||
type = VIDEO_ONLY;
|
type = VIDEO_ONLY;
|
||||||
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
case 'p':
|
case 'p':
|
||||||
if( ary_options[i].value[0] == 'P' || ary_options[i].value[0] == 'p' )
|
|
||||||
type = IMAGES_ONLY;
|
type = IMAGES_ONLY;
|
||||||
myval = index(ary_options[i].value, '/');
|
break;
|
||||||
case '/':
|
default:
|
||||||
path = realpath(myval ? myval:ary_options[i].value, buf);
|
DPRINTF(E_FATAL, L_GENERAL, "Media directory entry not understood [%s]\n",
|
||||||
if( !path )
|
ary_options[i].value);
|
||||||
path = (myval ? myval:ary_options[i].value);
|
break;
|
||||||
if( access(path, F_OK) != 0 )
|
}
|
||||||
|
path += 2;
|
||||||
|
}
|
||||||
|
path = realpath(path, buf);
|
||||||
|
if( !path || access(path, F_OK) != 0 )
|
||||||
{
|
{
|
||||||
DPRINTF(E_ERROR, L_GENERAL, "Media directory \"%s\" not accessible! [%s]\n",
|
DPRINTF(E_ERROR, L_GENERAL, "Media directory \"%s\" not accessible [%s]\n",
|
||||||
path, strerror(errno));
|
ary_options[i].value, strerror(errno));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
struct media_dir_s * this_dir = calloc(1, sizeof(struct media_dir_s));
|
struct media_dir_s * this_dir = calloc(1, sizeof(struct media_dir_s));
|
||||||
@ -488,12 +493,6 @@ init(int argc, char * * argv)
|
|||||||
all_dirs->next = this_dir;
|
all_dirs->next = this_dir;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
DPRINTF(E_ERROR, L_GENERAL, "Media directory entry not understood! [%s]\n",
|
|
||||||
ary_options[i].value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case UPNPALBUMART_NAMES:
|
case UPNPALBUMART_NAMES:
|
||||||
for( string = ary_options[i].value; (word = strtok(string, "/")); string = NULL )
|
for( string = ary_options[i].value; (word = strtok(string, "/")); string = NULL )
|
||||||
{
|
{
|
||||||
@ -1037,7 +1036,7 @@ main(int argc, char * * argv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* the comparaison is not very precise but who cares ? */
|
/* the comparison is not very precise but who cares ? */
|
||||||
if(timeofday.tv_sec >= (lastnotifytime.tv_sec + runtime_vars.notify_interval))
|
if(timeofday.tv_sec >= (lastnotifytime.tv_sec + runtime_vars.notify_interval))
|
||||||
{
|
{
|
||||||
SendSSDPNotifies2(snotify,
|
SendSSDPNotifies2(snotify,
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
#include "utils.h"
|
||||||
#include "upnpglobalvars.h"
|
#include "upnpglobalvars.h"
|
||||||
|
|
||||||
struct option * ary_options = NULL;
|
struct option * ary_options = NULL;
|
||||||
@ -169,7 +170,7 @@ readoptionsfile(const char * fname)
|
|||||||
ary_options = (struct option *)t;
|
ary_options = (struct option *)t;
|
||||||
|
|
||||||
ary_options[num_options-1].id = id;
|
ary_options[num_options-1].id = id;
|
||||||
strncpy(ary_options[num_options-1].value, value, MAX_OPTION_VALUE_LEN);
|
strncpyt(ary_options[num_options-1].value, value, MAX_OPTION_VALUE_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user