conf: added config_get_path()
config_get_path() is an simpler interface than parseConfigFilePath().
This commit is contained in:
parent
a3f03f3ccd
commit
9c6b2a32f5
18
src/conf.c
18
src/conf.c
@ -387,6 +387,24 @@ config_get_string(const char *name, const char *default_value)
|
|||||||
return param->value;
|
return param->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
config_get_path(const char *name)
|
||||||
|
{
|
||||||
|
struct config_param *param = config_get_param(name);
|
||||||
|
char *path;
|
||||||
|
|
||||||
|
if (param == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
path = parsePath(param->value);
|
||||||
|
if (path == NULL)
|
||||||
|
g_error("error parsing \"%s\" at line %i\n",
|
||||||
|
name, param->line);
|
||||||
|
|
||||||
|
g_free(param->value);
|
||||||
|
return param->value = path;
|
||||||
|
}
|
||||||
|
|
||||||
struct block_param *
|
struct block_param *
|
||||||
getBlockParam(struct config_param * param, const char *name)
|
getBlockParam(struct config_param * param, const char *name)
|
||||||
{
|
{
|
||||||
|
@ -101,6 +101,14 @@ config_get_param(const char *name)
|
|||||||
const char *
|
const char *
|
||||||
config_get_string(const char *name, const char *default_value);
|
config_get_string(const char *name, const char *default_value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an optional configuration variable which contains an
|
||||||
|
* absolute path. If there is a tilde prefix, it is expanded. Aborts
|
||||||
|
* MPD if the path is not a valid absolute path.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
config_get_path(const char *name);
|
||||||
|
|
||||||
struct block_param *
|
struct block_param *
|
||||||
getBlockParam(struct config_param *param, const char *name);
|
getBlockParam(struct config_param *param, const char *name);
|
||||||
|
|
||||||
|
11
src/main.c
11
src/main.c
@ -81,19 +81,20 @@ struct notify main_notify;
|
|||||||
|
|
||||||
static void openDB(Options * options, char *argv0)
|
static void openDB(Options * options, char *argv0)
|
||||||
{
|
{
|
||||||
struct config_param *param;
|
const char *path = config_get_path(CONF_DB_FILE);
|
||||||
|
|
||||||
param = parseConfigFilePath(CONF_DB_FILE,
|
|
||||||
mapper_has_music_directory());
|
|
||||||
if (!mapper_has_music_directory()) {
|
if (!mapper_has_music_directory()) {
|
||||||
if (param != NULL)
|
if (path != NULL)
|
||||||
g_message("Found " CONF_DB_FILE " setting without "
|
g_message("Found " CONF_DB_FILE " setting without "
|
||||||
CONF_MUSIC_DIR " - disabling database");
|
CONF_MUSIC_DIR " - disabling database");
|
||||||
db_init(NULL);
|
db_init(NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
db_init(param->value);
|
if (path == NULL)
|
||||||
|
g_error(CONF_DB_FILE " setting missing");
|
||||||
|
|
||||||
|
db_init(path);
|
||||||
|
|
||||||
if (options->createDB > 0 || !db_load()) {
|
if (options->createDB > 0 || !db_load()) {
|
||||||
unsigned job;
|
unsigned job;
|
||||||
|
Loading…
Reference in New Issue
Block a user