MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / get_models_directory

Function get_models_directory

src/common/utils.cpp:187–211  ·  view source on GitHub ↗

@brief get_models_directory gets the models directory from environment variable or defaults to user/.flm/models on Windows or ~/.config/flm on Linux @return the models directory path

Source from the content-addressed store, hash-verified

185///@brief get_models_directory gets the models directory from environment variable or defaults to user/.flm/models on Windows or ~/.config/flm on Linux
186///@return the models directory path
187std::string get_models_directory() {
188#ifdef _WIN32
189 char* model_path_env = nullptr;
190 size_t len = 0;
191 if (_dupenv_s(&model_path_env, &len, "FLM_MODEL_PATH") == 0 && model_path_env != nullptr) {
192 std::string custom_path(model_path_env);
193 free(model_path_env);
194 if (!custom_path.empty()) {
195 return custom_path;
196 }
197 }
198#else
199 const char* model_path_env = std::getenv("FLM_MODEL_PATH");
200 if (model_path_env && *model_path_env) {
201 return std::string(model_path_env);
202 }
203#endif
204 // Fallback to user/.flm/ on Windows or ~/.config/flm on Linux if environment variable is not set
205 std::string user_dir = get_user_directory();
206#ifdef _WIN32
207 return user_dir + "\\.flm";
208#else
209 return user_dir + "/flm";
210#endif
211}
212
213} // end of namespace utils

Callers 15

cmd_saveMethod · 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
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 2

get_user_directoryFunction · 0.85
emptyMethod · 0.45

Tested by 15

mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68