[Conf] Handle the case of using the default 'sysconfdir' value of meson
authorWook Song <wook16.song@samsung.com>
Fri, 24 May 2019 04:45:53 +0000 (13:45 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Thu, 25 Jul 2019 11:21:09 +0000 (20:21 +0900)
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 <wook16.song@samsung.com>
gst/nnstreamer/nnstreamer_conf.c
gst/nnstreamer/nnstreamer_conf.h

index acdb3f5..a70f717 100644 (file)
@@ -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);
index 4d0469a..8cf6352 100644 (file)
 #include <glib.h>
 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"