conf: removed parseConfigFilePath()

Use config_get_path() instead in mapper.c.
This commit is contained in:
Max Kellermann 2009-01-18 18:59:10 +01:00
parent a0603d8897
commit 70c6cc33f0
3 changed files with 19 additions and 46 deletions

View File

@ -425,29 +425,6 @@ getBlockParam(struct config_param * param, const char *name)
return ret; return ret;
} }
struct config_param *
parseConfigFilePath(const char *name, int force)
{
struct config_param *param = config_get_param(name);
char *path;
if (!param && force)
g_error("config parameter \"%s\" not found\n", name);
if (!param)
return NULL;
path = parsePath(param->value);
if (!path)
g_error("error parsing \"%s\" at line %i\n",
name, param->line);
g_free(param->value);
param->value = path;
return param;
}
bool config_get_bool(const char *name, bool default_value) bool config_get_bool(const char *name, bool default_value)
{ {
struct config_param *param = config_get_param(name); struct config_param *param = config_get_param(name);

View File

@ -112,9 +112,6 @@ 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);
struct config_param *
parseConfigFilePath(const char *name, int force);
bool config_get_bool(const char *name, bool default_value); bool config_get_bool(const char *name, bool default_value);
bool bool

View File

@ -41,7 +41,7 @@ static size_t music_dir_length;
static char *playlist_dir; static char *playlist_dir;
static void static void
mapper_set_music_dir(const char *path, int line) mapper_set_music_dir(const char *path)
{ {
int ret; int ret;
struct stat st; struct stat st;
@ -51,15 +51,15 @@ mapper_set_music_dir(const char *path, int line)
ret = stat(music_dir, &st); ret = stat(music_dir, &st);
if (ret < 0) if (ret < 0)
g_warning("failed to stat music directory \"%s\" (config line %i): %s\n", g_warning("failed to stat music directory \"%s\": %s",
music_dir, line, g_strerror(errno)); music_dir, g_strerror(errno));
else if (!S_ISDIR(st.st_mode)) else if (!S_ISDIR(st.st_mode))
g_warning("music directory is not a directory: \"%s\" (config line %i)\n", g_warning("music directory is not a directory: \"%s\"",
music_dir, line); music_dir);
} }
static void static void
mapper_set_playlist_dir(const char *path, int line) mapper_set_playlist_dir(const char *path)
{ {
int ret; int ret;
struct stat st; struct stat st;
@ -68,32 +68,31 @@ mapper_set_playlist_dir(const char *path, int line)
ret = stat(playlist_dir, &st); ret = stat(playlist_dir, &st);
if (ret < 0) if (ret < 0)
g_warning("failed to stat playlist directory \"%s\" (config line %i): %s\n", g_warning("failed to stat playlist directory \"%s\": %s",
playlist_dir, line, g_strerror(errno)); playlist_dir, g_strerror(errno));
else if (!S_ISDIR(st.st_mode)) else if (!S_ISDIR(st.st_mode))
g_warning("playlist directory is not a directory: \"%s\" (config line %i)\n", g_warning("playlist directory is not a directory: \"%s\"",
playlist_dir, line); playlist_dir);
} }
void mapper_init(void) void mapper_init(void)
{ {
struct config_param *param; const char *path;
param = parseConfigFilePath(CONF_MUSIC_DIR, false); path = config_get_path(CONF_MUSIC_DIR);
if (param != NULL) if (path != NULL)
mapper_set_music_dir(param->value, param->line); mapper_set_music_dir(path);
#if GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 14) #if GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 14)
else { else {
const char *path = path = g_get_user_special_dir(G_USER_DIRECTORY_MUSIC);
g_get_user_special_dir(G_USER_DIRECTORY_MUSIC);
if (path != NULL) if (path != NULL)
mapper_set_music_dir(path, -1); mapper_set_music_dir(path);
} }
#endif #endif
param = parseConfigFilePath(CONF_PLAYLIST_DIR, false); path = config_get_path(CONF_PLAYLIST_DIR);
if (param != NULL) if (path != NULL)
mapper_set_playlist_dir(param->value, param->line); mapper_set_playlist_dir(path);
} }
void mapper_finish(void) void mapper_finish(void)