From 3cea060685e833e24fb9182b7d37de8c600f9fdc Mon Sep 17 00:00:00 2001 From: Jeonghoon Park Date: Tue, 7 Nov 2017 14:53:03 +0900 Subject: [PATCH] get conf file path from app common api Change-Id: I5a12e0047e9255eca48b91d776269ce64b9e3cc7 --- src/controller_util.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/controller_util.c b/src/controller_util.c index b894f76..3bba0d5 100644 --- a/src/controller_util.c +++ b/src/controller_util.c @@ -21,12 +21,14 @@ #include #include - +#include +#include #include "log.h" #define CONF_GROUP_DEFAULT_NAME "default" #define CONF_KEY_PATH_NAME "path" #define CONF_KEY_ADDRESS_NAME "address" +#define CONF_FILE_NAME "pi.conf" struct controller_util_s { char *path; @@ -38,12 +40,20 @@ struct controller_util_s controller_util = { 0, }; static int _read_conf_file(void) { GKeyFile *gkf = NULL; + char conf_path[PATH_MAX] = {0,}; + char *prefix = NULL; gkf = g_key_file_new(); retv_if(!gkf, -1); - if (!g_key_file_load_from_file(gkf, CONF_FILE, G_KEY_FILE_NONE, NULL)) { - _E("could not read config file %s", CONF_FILE); + prefix = app_get_resource_path(); + retv_if(!prefix, -1); + snprintf(conf_path, sizeof(conf_path)-1, "%s%s", prefix, CONF_FILE_NAME); + free(prefix); + prefix = NULL; + + if (!g_key_file_load_from_file(gkf, conf_path, G_KEY_FILE_NONE, NULL)) { + _E("could not read config file %s", conf_path); return -1; } -- 2.7.4