// on success, return 0. otherwise return -1.
int initializePathManager(const std::string& runtimeDir, const std::string& tizenFXDir, const std::string& extraDir)
{
- if (!initializedPathManager) {
- __dllPath = new DllPath();
- if (!__dllPath) {
- _ERR("fail to allocate memory for dll path structure\n");
- return -1;
- }
-
- if (!runtimeDir.empty()) {
- __dllPath->runtime_dir = absolutePath(runtimeDir);
- } else {
- __dllPath->runtime_dir = absolutePath(__RUNTIME_DIR);
- }
+ if (initializedPathManager) {
+ _INFO("Path manager already initialized");
+ return 0;
+ }
- if (!tizenFXDir.empty()) {
- __dllPath->tizenfx_dir = absolutePath(tizenFXDir);
- } else {
- char* tmp = vconf_get_str(__TIZEN_API_PATH_KEY);
- if (tmp) {
- __dllPath->tizenfx_dir = std::string(tmp);
- _DBG("Device API Directory is set by vconf : %s", tmp);
- } else {
- __dllPath->tizenfx_dir = absolutePath(__DEVICE_API_DIR);
- }
- }
+ __dllPath = new DllPath();
+ if (!__dllPath) {
+ _ERR("fail to allocate memory for dll path structure\n");
+ return -1;
+ }
- __dllPath->tizenfx_ref_dir = __dllPath->tizenfx_dir + "/ref";
+ if (!runtimeDir.empty()) {
+ __dllPath->runtime_dir = absolutePath(runtimeDir);
+ } else {
+ __dllPath->runtime_dir = absolutePath(__RUNTIME_DIR);
+ }
- // ":" seperated extra directories
- if (!extraDir.empty()) {
- splitPath(extraDir, __dllPath->extra_dirs);
+ if (!tizenFXDir.empty()) {
+ __dllPath->tizenfx_dir = absolutePath(tizenFXDir);
+ } else {
+ char* tmp = vconf_get_str(__TIZEN_API_PATH_KEY);
+ if (tmp) {
+ __dllPath->tizenfx_dir = std::string(tmp);
+ _DBG("Device API Directory is set by vconf : %s", tmp);
+ free(tmp);
} else {
- char* extraPath = pluginGetDllPath();
- if (extraPath) {
- splitPath(extraPath, __dllPath->extra_dirs);
- }
+ __dllPath->tizenfx_dir = absolutePath(__DEVICE_API_DIR);
}
+ }
+
+ __dllPath->tizenfx_ref_dir = __dllPath->tizenfx_dir + "/ref";
- _INFO("Path manager initialize success");
+ // ":" seperated extra directories
+ if (!extraDir.empty()) {
+ splitPath(extraDir, __dllPath->extra_dirs);
} else {
- _INFO("Skip to initialize Path manager");
+ char* extraPath = pluginGetDllPath();
+ if (extraPath) {
+ splitPath(extraPath, __dllPath->extra_dirs);
+ }
}
+
+ _INFO("Path manager initialize success");
+
initializedPathManager = true;
return 0;
}
delete __dllPath;
__dllPath = NULL;
}
+
initializedPathManager = false;
}