Skip to content

Commit c543fd0

Browse files
Update common.cpp
Cosmo - Find the user's cache directory when we don't know what OS they are on at compile time. Signed-off-by: Brad Hutchings <[email protected]>
1 parent 9b230e3 commit c543fd0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

common/common.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,21 @@ std::string fs_get_cache_directory() {
840840
cache_directory = std::getenv("HOME") + std::string("/Library/Caches/");
841841
#elif defined(_WIN32)
842842
cache_directory = std::getenv("LOCALAPPDATA");
843+
844+
// llama-server-one START
845+
#elif defined(COSMOCC)
846+
// We don't know what OS we are running on at compile time, just CPU architecture.
847+
// try various environment variables, fall back to ~/.cache.
848+
// FUTURE: Checkj if the directories actually exist.
849+
cache_directory = std::getenv("LOCALAPPDATA");
850+
if (cache_directory == "") {
851+
cache_directory = std::getenv("XDG_CACHE_HOME");
852+
}
853+
if (cache_directory == "") {
854+
cache_directory = std::getenv("HOME") + std::string("/.cache/");
855+
}
856+
857+
// llama-server-one END
843858
#else
844859
# error Unknown architecture
845860
#endif

0 commit comments

Comments
 (0)