From: Jeonghoon Park Date: Tue, 7 Nov 2017 05:53:03 +0000 (+0900) Subject: get conf file path from app common api X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3cea060685e833e24fb9182b7d37de8c600f9fdc;p=apps%2Fnative%2Fposition-finder-server.git get conf file path from app common api Change-Id: I5a12e0047e9255eca48b91d776269ce64b9e3cc7 --- 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; }