Commit 06514aec authored by Max Kellermann's avatar Max Kellermann

fs/StandardDirectory: add GetAppCacheDir()

parent 4ded1ae6
...@@ -291,6 +291,24 @@ GetUserCacheDir() noexcept ...@@ -291,6 +291,24 @@ GetUserCacheDir() noexcept
} }
AllocatedPath 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 GetUserRuntimeDir() noexcept
{ {
#ifdef USE_XDG #ifdef USE_XDG
......
...@@ -44,6 +44,13 @@ AllocatedPath ...@@ -44,6 +44,13 @@ AllocatedPath
GetUserCacheDir() noexcept; GetUserCacheDir() noexcept;
/** /**
* Obtains cache directory for this application.
*/
[[gnu::const]]
AllocatedPath
GetAppCacheDir() noexcept;
/**
* Obtains the runtime directory for the current user. * Obtains the runtime directory for the current user.
*/ */
[[gnu::const]] [[gnu::const]]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment