MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / fs_get_cache_directory

Function fs_get_cache_directory

smallthinker/tools/rpc/rpc-server.cpp:102–131  ·  view source on GitHub ↗

NOTE: this is copied from common.cpp to avoid linking with libcommon

Source from the content-addressed store, hash-verified

100
101// NOTE: this is copied from common.cpp to avoid linking with libcommon
102static std::string fs_get_cache_directory() {
103 std::string cache_directory = "";
104 auto ensure_trailing_slash = [](std::string p) {
105 // Make sure to add trailing slash
106 if (p.back() != DIRECTORY_SEPARATOR) {
107 p += DIRECTORY_SEPARATOR;
108 }
109 return p;
110 };
111 if (getenv("LLAMA_CACHE")) {
112 cache_directory = std::getenv("LLAMA_CACHE");
113 } else {
114#if defined(__linux__) || defined(__FreeBSD__) || defined(_AIX) || defined(__OpenBSD__)
115 if (std::getenv("XDG_CACHE_HOME")) {
116 cache_directory = std::getenv("XDG_CACHE_HOME");
117 } else {
118 cache_directory = std::getenv("HOME") + std::string("/.cache/");
119 }
120#elif defined(__APPLE__)
121 cache_directory = std::getenv("HOME") + std::string("/Library/Caches/");
122#elif defined(_WIN32)
123 cache_directory = std::getenv("LOCALAPPDATA");
124#else
125# error Unknown architecture
126#endif
127 cache_directory = ensure_trailing_slash(cache_directory);
128 cache_directory += "llama.cpp";
129 }
130 return ensure_trailing_slash(cache_directory);
131}
132
133struct rpc_server_params {
134 std::string host = "127.0.0.1";

Callers 1

mainFunction · 0.70

Calls 1

stringClass · 0.50

Tested by

no test coverage detected