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

Function get_file

examples/common/common.cpp:102–130  ·  view source on GitHub ↗

! * @brief Find the model file or label file according to the file name * @param fname The model file name or label file name * @return The fullname of the file that founded * @note Firstly, search the file in current directory; * if failed, search the file in "Tengine_root/models/"; * if still failed, display error message and return empty string. */

Source from the content-addressed store, hash-verified

100 * if still failed, display error message and return empty string.
101 */
102std::string get_file(const char* fname)
103{
104 FILE* fp;
105 std::string fn = fname;
106
107 const std::string mod_sch1 = "./" + fn;
108 const std::string mod_sch2 = get_root_path() + "models/" + fn;
109
110 fp = fopen(mod_sch1.c_str(), "r");
111 if(fp)
112 {
113 fclose(fp);
114 return mod_sch1;
115 }
116 else
117 {
118 fp = fopen(mod_sch2.c_str(), "r");
119 if(fp)
120 {
121 fclose(fp);
122 return mod_sch2;
123 }
124 else
125 {
126 std::cerr << "Can't find " << fn << " in current dir and models dir.\n";
127 return std::string("");
128 }
129 }
130}
131
132bool check_file_exist(const std::string file_name)
133{

Callers 5

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 2

get_root_pathFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected