File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -1855,11 +1855,15 @@ bool fs_create_directory_with_parents(const std::string & path) {
1855
1855
1856
1856
std::string fs_get_cache_directory () {
1857
1857
std::string cache_directory = " " ;
1858
+ auto ensure_trailing_slash = [](std::string p) {
1859
+ // Make sure to add trailing slash
1860
+ if (p.back () != DIRECTORY_SEPARATOR) {
1861
+ p += DIRECTORY_SEPARATOR;
1862
+ }
1863
+ return p;
1864
+ };
1858
1865
if (getenv (" LLAMA_CACHE" )) {
1859
1866
cache_directory = std::getenv (" LLAMA_CACHE" );
1860
- if (cache_directory.back () != DIRECTORY_SEPARATOR) {
1861
- cache_directory += DIRECTORY_SEPARATOR;
1862
- }
1863
1867
} else {
1864
1868
#ifdef __linux__
1865
1869
if (std::getenv (" XDG_CACHE_HOME" )) {
@@ -1870,12 +1874,12 @@ std::string fs_get_cache_directory() {
1870
1874
#elif defined(__APPLE__)
1871
1875
cache_directory = std::getenv (" HOME" ) + std::string (" /Library/Caches/" );
1872
1876
#elif defined(_WIN32)
1873
- cache_directory = std::getenv (" APPDATA " );
1877
+ cache_directory = std::getenv (" LOCALAPPDATA " );
1874
1878
#endif // __linux__
1879
+ cache_directory = ensure_trailing_slash (cache_directory);
1875
1880
cache_directory += " llama.cpp" ;
1876
- cache_directory += DIRECTORY_SEPARATOR;
1877
1881
}
1878
- return cache_directory;
1882
+ return ensure_trailing_slash ( cache_directory) ;
1879
1883
}
1880
1884
1881
1885
You can’t perform that action at this time.
0 commit comments