2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include "plugin_manager.h"
26 static const char* __TIZEN_API_PATH_KEY = "db/dotnet/tizen_api_path";
29 #define __STR(x) __XSTR(x)
30 static const char* __DEVICE_API_DIR = __STR(DEVICE_API_DIR);
31 static const char* __RUNTIME_DIR = __STR(RUNTIME_DIR);
35 typedef struct DllPath {
36 std::string runtime_dir;
37 std::string tizenfx_dir;
38 std::string tizenfx_ref_dir;
39 std::vector <std::string>extra_dirs;
42 static DllPath* __dllPath = nullptr;
43 static std::string __tpa;
45 // on success, return 0. otherwise return -1.
46 int initializePathManager(const std::string& runtimeDir, const std::string& tizenFXDir, const std::string& extraDir)
48 __dllPath = new DllPath();
50 _ERR("fail to allocate memory for dll path structure\n");
54 if (!runtimeDir.empty()) {
55 __dllPath->runtime_dir = absolutePath(runtimeDir);
57 __dllPath->runtime_dir = absolutePath(__RUNTIME_DIR);
60 if (!tizenFXDir.empty()) {
61 __dllPath->tizenfx_dir = absolutePath(tizenFXDir);
63 char* tmp = vconf_get_str(__TIZEN_API_PATH_KEY);
65 __dllPath->tizenfx_dir = std::string(tmp);
66 _DBG("Device API Directory is set by vconf : %s", tmp);
68 __dllPath->tizenfx_dir = absolutePath(__DEVICE_API_DIR);
72 __dllPath->tizenfx_ref_dir = __dllPath->tizenfx_dir + "/ref";
74 // ":" seperated extra directories
75 if (!extraDir.empty()) {
76 splitPath(extraDir, __dllPath->extra_dirs);
78 char* extraPath = pluginGetDllPath();
80 splitPath(extraPath, __dllPath->extra_dirs);
84 _INFO("Path manager initialize success");
89 void finalizePathManager()
97 std::string getRuntimeDir()
99 return __dllPath->runtime_dir;
102 std::string getTizenFXDir()
104 return __dllPath->tizenfx_dir;
107 std::string getTizenFXRefDir()
109 return __dllPath->tizenfx_ref_dir;
112 std::vector <std::string> getExtraDirs()
114 return __dllPath->extra_dirs;
119 if (!__tpa.empty()) {
123 std::vector<std::string> tpaDir;
125 if (__dllPath == NULL) {
126 return std::string("");
129 tpaDir.push_back(getRuntimeDir());
130 tpaDir.push_back(getTizenFXDir());
131 tpaDir.push_back(getTizenFXRefDir());
132 tpaDir.insert(tpaDir.end(), __dllPath->extra_dirs.begin(), __dllPath->extra_dirs.end());
133 assembliesInDirectory(tpaDir, __tpa);