diff options
author | Max Kellermann <max@duempel.org> | 2013-08-07 19:54:38 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-08-07 19:59:09 +0200 |
commit | b76a29a69ae5412c3c1d101eefa9562990e74407 (patch) | |
tree | 5c60aa1bb5e6a8d134707291d12fb4ebb77c06c8 /src/Main.cxx | |
parent | abe090ec1f2255ce422f74e5b59bffc83aaff875 (diff) | |
download | mpd-b76a29a69ae5412c3c1d101eefa9562990e74407.tar.gz mpd-b76a29a69ae5412c3c1d101eefa9562990e74407.tar.xz mpd-b76a29a69ae5412c3c1d101eefa9562990e74407.zip |
ConfigPath: return a Path object
Migrate all callers to use Path directly, instead of doing the
conversion in each caller.
Diffstat (limited to 'src/Main.cxx')
-rw-r--r-- | src/Main.cxx | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/src/Main.cxx b/src/Main.cxx index 42403922c..56f5b2c07 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -111,16 +111,15 @@ glue_daemonize_init(const struct options *options, GError **error_r) { GError *error = NULL; - char *pid_file = config_dup_path(CONF_PID_FILE, &error); - if (pid_file == NULL && error != NULL) { + Path pid_file = config_get_path(CONF_PID_FILE, &error); + if (pid_file.IsNull() && error != NULL) { g_propagate_error(error_r, error); return false; } daemonize_init(config_get_string(CONF_USER, NULL), config_get_string(CONF_GROUP, NULL), - pid_file); - g_free(pid_file); + std::move(pid_file)); if (options->kill) daemonize_kill(); @@ -132,28 +131,22 @@ static bool glue_mapper_init(GError **error_r) { GError *error = NULL; - char *music_dir = config_dup_path(CONF_MUSIC_DIR, &error); - if (music_dir == NULL && error != NULL) { + Path music_dir = config_get_path(CONF_MUSIC_DIR, &error); + if (music_dir.IsNull() && error != NULL) { g_propagate_error(error_r, error); return false; } - char *playlist_dir = config_dup_path(CONF_PLAYLIST_DIR, &error); - if (playlist_dir == NULL && error != NULL) { + Path playlist_dir = config_get_path(CONF_PLAYLIST_DIR, &error); + if (playlist_dir.IsNull() && error != NULL) { g_propagate_error(error_r, error); return false; } - if (music_dir == NULL) - music_dir = g_strdup(g_get_user_special_dir(G_USER_DIRECTORY_MUSIC)); + if (music_dir.IsNull()) + music_dir = Path::FromUTF8(g_get_user_special_dir(G_USER_DIRECTORY_MUSIC)); - if (!mapper_init(music_dir, playlist_dir, &error)) { - g_propagate_error(error_r, error); - return false; - } - - g_free(music_dir); - g_free(playlist_dir); + mapper_init(std::move(music_dir), std::move(playlist_dir)); return true; } @@ -213,14 +206,12 @@ glue_sticker_init(void) { #ifdef ENABLE_SQLITE GError *error = NULL; - char *sticker_file = config_dup_path(CONF_STICKER_FILE, &error); - if (sticker_file == NULL && error != NULL) + Path sticker_file = config_get_path(CONF_STICKER_FILE, &error); + if (sticker_file.IsNull() && error != NULL) FatalError(error); - if (!sticker_global_init(sticker_file, &error)) + if (!sticker_global_init(std::move(sticker_file), &error)) FatalError(error); - - g_free(sticker_file); #endif } @@ -229,8 +220,8 @@ glue_state_file_init(GError **error_r) { GError *error = NULL; - char *path = config_dup_path(CONF_STATE_FILE, &error); - if (path == nullptr) { + Path path_fs = config_get_path(CONF_STATE_FILE, &error); + if (path_fs.IsNull()) { if (error != nullptr) { g_propagate_error(error_r, error); return false; @@ -239,19 +230,14 @@ glue_state_file_init(GError **error_r) return true; } - Path path_fs = Path::FromUTF8(path); - if (path_fs.IsNull()) { - g_free(path); g_set_error(error_r, main_quark(), 0, "Failed to convert state file path to FS encoding"); return false; } - state_file = new StateFile(std::move(path_fs), path, + state_file = new StateFile(std::move(path_fs), *instance->partition, *main_loop); - g_free(path); - state_file->Read(); return true; } |