From cf15629aeae7b2f750388c6823f43cd5918676a4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 28 Nov 2011 09:35:50 +0100 Subject: [PATCH] mapper: move code to check_directory() --- src/mapper.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/mapper.c b/src/mapper.c index 108de9531..426b2980f 100644 --- a/src/mapper.c +++ b/src/mapper.c @@ -51,25 +51,28 @@ strdup_chop_slash(const char *path_fs) return g_strndup(path_fs, length); } +static void +check_directory(const char *path) +{ + if (!g_file_test(path, G_FILE_TEST_IS_DIR)) + g_warning("Not a directory: %s", path); +} + static void mapper_set_music_dir(const char *path) { + check_directory(path); + music_dir = strdup_chop_slash(path); music_dir_length = strlen(music_dir); - - if (!g_file_test(music_dir, G_FILE_TEST_IS_DIR)) - g_warning("music directory is not a directory: \"%s\"", - music_dir); } static void mapper_set_playlist_dir(const char *path) { - playlist_dir = g_strdup(path); + check_directory(path); - if (!g_file_test(playlist_dir, G_FILE_TEST_IS_DIR)) - g_warning("playlist directory is not a directory: \"%s\"", - playlist_dir); + playlist_dir = g_strdup(path); } void mapper_init(const char *_music_dir, const char *_playlist_dir)