mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-31 08:51:55 +00:00 
			
		
		
		
	fix missing slash in fs_get_cache_directory() (#7503)
				
					
				
			* fix missing slash in fs_get_cache_directory() * use LOCALAPPDATA for fs_get_cache_directory() * better code style
This commit is contained in:
		| @@ -1855,11 +1855,15 @@ bool fs_create_directory_with_parents(const std::string & path) { | |||||||
|  |  | ||||||
| std::string fs_get_cache_directory() { | std::string fs_get_cache_directory() { | ||||||
|     std::string cache_directory = ""; |     std::string cache_directory = ""; | ||||||
|  |     auto ensure_trailing_slash = [](std::string p) { | ||||||
|  |         // Make sure to add trailing slash | ||||||
|  |         if (p.back() != DIRECTORY_SEPARATOR) { | ||||||
|  |             p += DIRECTORY_SEPARATOR; | ||||||
|  |         } | ||||||
|  |         return p; | ||||||
|  |     }; | ||||||
|     if (getenv("LLAMA_CACHE")) { |     if (getenv("LLAMA_CACHE")) { | ||||||
|         cache_directory = std::getenv("LLAMA_CACHE"); |         cache_directory = std::getenv("LLAMA_CACHE"); | ||||||
|         if (cache_directory.back() != DIRECTORY_SEPARATOR) { |  | ||||||
|             cache_directory += DIRECTORY_SEPARATOR; |  | ||||||
|         } |  | ||||||
|     } else { |     } else { | ||||||
| #ifdef __linux__ | #ifdef __linux__ | ||||||
|         if (std::getenv("XDG_CACHE_HOME")) { |         if (std::getenv("XDG_CACHE_HOME")) { | ||||||
| @@ -1870,12 +1874,12 @@ std::string fs_get_cache_directory() { | |||||||
| #elif defined(__APPLE__) | #elif defined(__APPLE__) | ||||||
|         cache_directory = std::getenv("HOME") + std::string("/Library/Caches/"); |         cache_directory = std::getenv("HOME") + std::string("/Library/Caches/"); | ||||||
| #elif defined(_WIN32) | #elif defined(_WIN32) | ||||||
|         cache_directory = std::getenv("APPDATA"); |         cache_directory = std::getenv("LOCALAPPDATA"); | ||||||
| #endif // __linux__ | #endif // __linux__ | ||||||
|  |         cache_directory = ensure_trailing_slash(cache_directory); | ||||||
|         cache_directory += "llama.cpp"; |         cache_directory += "llama.cpp"; | ||||||
|         cache_directory += DIRECTORY_SEPARATOR; |  | ||||||
|     } |     } | ||||||
|     return cache_directory; |     return ensure_trailing_slash(cache_directory); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Xuan Son Nguyen
					Xuan Son Nguyen