fs/StandardDirectory: look for cache dir in environment, not user-dirs
The XDG cache directory is part of the "base directories" spec like $XDG_CONFIG_HOME, not "user directories".
This commit is contained in:

committed by
Max Kellermann

parent
b123392592
commit
cd289843f7
@@ -254,11 +254,23 @@ AllocatedPath GetUserMusicDir()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocatedPath
|
AllocatedPath GetUserCacheDir()
|
||||||
GetUserCacheDir()
|
|
||||||
{
|
{
|
||||||
#ifdef USE_XDG
|
#ifdef USE_XDG
|
||||||
return GetUserDir("XDG_CACHE_DIR");
|
// Check for $XDG_CACHE_HOME
|
||||||
|
auto cache_home = getenv("XDG_CACHE_HOME");
|
||||||
|
if (IsValidPathString(cache_home) && IsValidDir(cache_home))
|
||||||
|
return AllocatedPath::FromFS(cache_home);
|
||||||
|
|
||||||
|
// Check for $HOME/.cache
|
||||||
|
auto home = GetHomeDir();
|
||||||
|
if (!home.IsNull()) {
|
||||||
|
AllocatedPath fallback = AllocatedPath::Build(home, ".cache");
|
||||||
|
if (IsValidDir(fallback.c_str()))
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
return AllocatedPath::Null();
|
||||||
#elif defined(ANDROID)
|
#elif defined(ANDROID)
|
||||||
return context->GetCacheDir(Java::GetEnv());
|
return context->GetCacheDir(Java::GetEnv());
|
||||||
#else
|
#else
|
||||||
|
Reference in New Issue
Block a user