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

Function fs_get_cache_directory

smallthinker/common/common.cpp:842–871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

840}
841
842std::string fs_get_cache_directory() {
843 std::string cache_directory = "";
844 auto ensure_trailing_slash = [](std::string p) {
845 // Make sure to add trailing slash
846 if (p.back() != DIRECTORY_SEPARATOR) {
847 p += DIRECTORY_SEPARATOR;
848 }
849 return p;
850 };
851 if (getenv("LLAMA_CACHE")) {
852 cache_directory = std::getenv("LLAMA_CACHE");
853 } else {
854#if defined(__linux__) || defined(__FreeBSD__) || defined(_AIX) || defined(__OpenBSD__)
855 if (std::getenv("XDG_CACHE_HOME")) {
856 cache_directory = std::getenv("XDG_CACHE_HOME");
857 } else {
858 cache_directory = std::getenv("HOME") + std::string("/.cache/");
859 }
860#elif defined(__APPLE__)
861 cache_directory = std::getenv("HOME") + std::string("/Library/Caches/");
862#elif defined(_WIN32)
863 cache_directory = std::getenv("LOCALAPPDATA");
864#else
865# error Unknown architecture
866#endif
867 cache_directory = ensure_trailing_slash(cache_directory);
868 cache_directory += "llama.cpp";
869 }
870 return ensure_trailing_slash(cache_directory);
871}
872
873std::string fs_get_cache_file(const std::string & filename) {
874 GGML_ASSERT(filename.find(DIRECTORY_SEPARATOR) == std::string::npos);

Callers 1

fs_get_cache_fileFunction · 0.70

Calls 1

stringClass · 0.50

Tested by

no test coverage detected