MCPcopy Create free account
hub / github.com/alibaba/MNN / GetBaseCacheDir

Method GetBaseCacheDir

apps/mnncli/src/cli_config_manager.cpp:172–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172std::string ConfigManager::GetBaseCacheDir() const {
173 std::string cache_dir = GetCacheDir();
174
175#ifdef __ANDROID__
176 // On Android, use current working directory as base for relative path
177 std::string expanded_cache_dir = FileUtils::ExpandTilde(cache_dir);
178
179 if (expanded_cache_dir.empty()) {
180 fprintf(stderr, "Unable to get cache directory path.");
181 return ""; // Handle error appropriately in your application
182 }
183
184 // Get current working directory and append the cache path
185 std::filesystem::path cwd = std::filesystem::current_path();
186 std::filesystem::path cache_path = cwd / expanded_cache_dir;
187#else
188 // On other platforms, use the home directory
189 std::string expanded_cache_dir = FileUtils::ExpandTilde(cache_dir);
190
191 if (expanded_cache_dir.empty()) {
192 fprintf(stderr, "Unable to get home directory.");
193 return ""; // Handle error appropriately in your application
194 }
195
196 std::filesystem::path cache_path(expanded_cache_dir);
197#endif
198
199 if (!fs::exists(cache_path)) {
200 fs::create_directories(cache_path);
201 }
202
203 return cache_path.string();
204}
205
206std::string ConfigManager::GetDownloadProvider() const {
207 return current_config_.download_provider.empty() ? "huggingface" : current_config_.download_provider;

Callers 5

SearchRemoteModelsMethod · 0.45
DownloadModelMethod · 0.45
ShowModelInfoMethod · 0.45
ListLocalModelsInnerMethod · 0.45
ListLocalModelsMethod · 0.45

Calls 4

existsFunction · 0.85
create_directoriesFunction · 0.85
emptyMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected