From 427319b72e871ac1fd723d11a9c42b954323845c Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Fri, 5 Feb 2016 07:57:22 -0500 Subject: [PATCH] core/file: Move OCARINA_NAME configuration into version.h I'm going to use this for saving album art to the right place. I moved it into an include file to avoid duplicating code. Signed-off-by: Anna Schumaker --- core/file.c | 11 ++--------- include/core/version.h | 8 ++++++++ tests/core/version.c | 1 + 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/core/file.c b/core/file.c index ad54e17b..89a08a02 100644 --- a/core/file.c +++ b/core/file.c @@ -3,23 +3,16 @@ */ #include #include +#include #include -#ifdef CONFIG_TESTING -const gchar *OCARINA_DIR = "ocarina-test"; -#elif CONFIG_DEBUG -const gchar *OCARINA_DIR = "ocarina-debug"; -#else -const gchar *OCARINA_DIR = "ocarina"; -#endif - #define REPORT_ERROR(fname) \ printf("%s (%s:%d): %s: %s\n", __func__, __FILE__, __LINE__, fname, strerror(errno)) static gchar *__file_path(gchar *name) { - return g_strjoin("/", g_get_user_data_dir(), OCARINA_DIR, name, NULL); + return g_strjoin("/", g_get_user_data_dir(), OCARINA_NAME, name, NULL); } static bool __file_mkdir() diff --git a/include/core/version.h b/include/core/version.h index 82801b1a..686dc4b2 100644 --- a/include/core/version.h +++ b/include/core/version.h @@ -4,6 +4,14 @@ #ifndef OCARINA_CORE_VERSION_H #define OCARINA_CORE_VERSION_H +#ifdef CONFIG_TESTING +#define OCARINA_NAME "ocarina-test" +#elif CONFIG_DEBUG +#define OCARINA_NAME "ocarina-debug" +#else +#define OCARINA_NAME "ocarina" +#endif + /* * Scons sets the current version by passing the * -DCONFIG_VERSION macro when Ocarina is compiled. diff --git a/tests/core/version.c b/tests/core/version.c index 99c24853..d8961d51 100644 --- a/tests/core/version.c +++ b/tests/core/version.c @@ -7,6 +7,7 @@ static void test_version() { test_equal(get_version(), CONFIG_VERSION); + test_equal(OCARINA_NAME, "ocarina-test"); } DECLARE_UNIT_TESTS(