From 3b24cb3c982931bf45fda320d3472c0233974489 Mon Sep 17 00:00:00 2001 From: Wook Song Date: Fri, 24 May 2019 13:45:53 +0900 Subject: [PATCH] [Conf] Handle the case of using the default 'sysconfdir' value of meson Since the default value of 'sysconfdir' in the Meson build system is just 'etc' instead of '/etc', NNSTREAMER_CONF_FILE could be set to wrong path when the default value is used. This patch fixes this issue. Signed-off-by: Wook Song --- gst/nnstreamer/nnstreamer_conf.c | 10 +++++++++- gst/nnstreamer/nnstreamer_conf.h | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gst/nnstreamer/nnstreamer_conf.c b/gst/nnstreamer/nnstreamer_conf.c index acdb3f5..a70f717 100644 --- a/gst/nnstreamer/nnstreamer_conf.c +++ b/gst/nnstreamer/nnstreamer_conf.c @@ -235,6 +235,7 @@ _fill_in_vstr (gchar *** fullpath_vstr, gchar *** basename_vstr, gboolean nnsconf_loadconf (gboolean force_reload) { + const gchar root_path_prefix[] = NNSTREAMER_SYS_ROOT_PATH_PREFIX; g_autoptr (GKeyFile) key_file = NULL; guint i; @@ -265,7 +266,14 @@ nnsconf_loadconf (gboolean force_reload) } /* Read from the conf file first */ - conf.conffile = g_strdup (NNSTREAMER_CONF_FILE); + if (g_path_is_absolute (NNSTREAMER_CONF_FILE)) { + conf.conffile = g_strdup (NNSTREAMER_CONF_FILE); + } else { + /** default value of 'sysconfdir' in meson is 'etc' */ + conf.conffile = g_build_path (G_DIR_SEPARATOR_S, root_path_prefix, + NNSTREAMER_CONF_FILE, NULL); + } + if (!g_file_test (conf.conffile, G_FILE_TEST_IS_REGULAR)) { /* File not found or not configured */ g_free (conf.conffile); diff --git a/gst/nnstreamer/nnstreamer_conf.h b/gst/nnstreamer/nnstreamer_conf.h index 4d0469a..8cf6352 100644 --- a/gst/nnstreamer/nnstreamer_conf.h +++ b/gst/nnstreamer/nnstreamer_conf.h @@ -36,6 +36,13 @@ #include G_BEGIN_DECLS +/* Hard-coded system-dependent root path prefix */ +#ifdef G_OS_WIN32 +#define NNSTREAMER_SYS_ROOT_PATH_PREFIX "c:\\" +#else +#define NNSTREAMER_SYS_ROOT_PATH_PREFIX "/" +#endif /* G_OS_WIN32 */ + /* Env-var names */ #define NNSTREAMER_ENVVAR_CONF_FILE "NNSTREAMER_CONF" #define NNSTREAMER_ENVVAR_FILTERS "NNSTREAMER_FILTERS" -- 2.7.4