MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / get_cache_directory

Function get_cache_directory

common/hf-cache.cpp:38–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36namespace fs = std::filesystem;
37
38static fs::path get_cache_directory() {
39 static const fs::path cache = []() {
40 struct {
41 const char * var;
42 fs::path path;
43 } entries[] = {
44 {"LLAMA_CACHE", fs::path()},
45 {"HF_HUB_CACHE", fs::path()},
46 {"HUGGINGFACE_HUB_CACHE", fs::path()},
47 {"HF_HOME", fs::path("hub")},
48 {"XDG_CACHE_HOME", fs::path("huggingface") / "hub"},
49 {HOME_DIR, fs::path(".cache") / "huggingface" / "hub"}
50 };
51 for (const auto & entry : entries) {
52 if (auto * p = std::getenv(entry.var); p && *p) {
53 fs::path base(p);
54 return entry.path.empty() ? base : base / entry.path;
55 }
56 }
57#ifndef _WIN32
58 const struct passwd * pw = getpwuid(getuid());
59
60 if (pw->pw_dir && *pw->pw_dir) {
61 return fs::path(pw->pw_dir) / ".cache" / "huggingface" / "hub";
62 }
63#endif
64 throw std::runtime_error("Failed to determine HF cache directory");
65 }();
66
67 return cache;
68}
69
70static std::string folder_name_to_repo(const std::string & folder) {
71 constexpr std::string_view prefix = "models--";

Callers 3

get_repo_pathFunction · 0.85
get_cached_filesFunction · 0.85

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected