fs/StandardDirectory: add GetAppCacheDir()

This commit is contained in:
Max Kellermann 2022-11-28 10:39:28 +01:00
parent 4ded1ae67b
commit 06514aec63
2 changed files with 25 additions and 0 deletions

View File

@ -290,6 +290,24 @@ GetUserCacheDir() noexcept
#endif
}
AllocatedPath
GetAppCacheDir() noexcept
{
#ifdef USE_XDG
if (const auto user_dir = GetUserCacheDir(); !user_dir.IsNull()) {
auto dir = user_dir / app_filename;
CreateDirectoryNoThrow(dir);
return dir;
}
return nullptr;
#elif defined(ANDROID)
return context->GetCacheDir(Java::GetEnv());
#else
return nullptr;
#endif
}
AllocatedPath
GetUserRuntimeDir() noexcept
{

View File

@ -43,6 +43,13 @@ GetUserMusicDir() noexcept;
AllocatedPath
GetUserCacheDir() noexcept;
/**
* Obtains cache directory for this application.
*/
[[gnu::const]]
AllocatedPath
GetAppCacheDir() noexcept;
/**
* Obtains the runtime directory for the current user.
*/