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 <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-02-05 07:57:22 -05:00
parent 98faba93d1
commit 427319b72e
3 changed files with 11 additions and 9 deletions

View File

@ -3,23 +3,16 @@
*/
#include <core/file.h>
#include <core/string.h>
#include <core/version.h>
#include <errno.h>
#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()

View File

@ -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.

View File

@ -7,6 +7,7 @@
static void test_version()
{
test_equal(get_version(), CONFIG_VERSION);
test_equal(OCARINA_NAME, "ocarina-test");
}
DECLARE_UNIT_TESTS(