MCPcopy Create free account
hub / github.com/OAID/Tengine / get_root_path

Function get_root_path

examples/common/common.cpp:14–42  ·  view source on GitHub ↗

! * @brief Get the Tengine root path * @return The string of Tengine root path(e.g. "/home/user/tengine/") * @note Firstly, assume the program is under "Tengine_root/build/examples/..."; if failed, then assume the program is under "Tengine_root/examples/..."; * if failed, then assume the program is under Tengine_root; * if failed again, then return an empty string. */

Source from the content-addressed store, hash-verified

12* if failed again, then return an empty string.
13*/
14std::string get_root_path(void)
15{
16 typedef std::string::size_type pos;
17 char buf[1024];
18
19 int rslt = readlink("/proc/self/exe", buf, 1023);
20 if(rslt < 0 || rslt > 1023)
21 {
22 return std::string("");
23 }
24 buf[rslt] = '\0';
25
26 std::string str = buf;
27 std::cout << str << std::endl;
28 pos p = str.find("build/examples/");
29 if(p == std::string::npos)
30 {
31 p = str.find("examples/");
32 if(p == std::string::npos)
33 {
34 p = str.find("tengine/");
35 if(p == std::string::npos)
36 return std::string("");
37 else
38 return str.substr(0, p + 8);
39 }
40 }
41 return str.substr(0, p);
42}
43
44/*!
45 * @brief Find the config file and set it to tengine

Callers 14

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
set_tengine_configFunction · 0.85
get_fileFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68