From 36ca57a54ebcbdfb2fa4374378280867a089bb91 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 1 Mar 2014 22:50:11 +0100 Subject: fs/StandardDirectory: add GetUserCacheDir() Move code from CreateConfiguredDatabase() and add XDG support. This implements an automatic Linux fallback for the setting "db_file" if none was specified. --- src/fs/StandardDirectory.cxx | 14 ++++++++++++++ src/fs/StandardDirectory.hxx | 7 +++++++ 2 files changed, 21 insertions(+) (limited to 'src/fs') diff --git a/src/fs/StandardDirectory.cxx b/src/fs/StandardDirectory.cxx index 20d66bb10..6456c0254 100644 --- a/src/fs/StandardDirectory.cxx +++ b/src/fs/StandardDirectory.cxx @@ -50,6 +50,8 @@ #ifdef ANDROID #include "java/Global.hxx" #include "android/Environment.hxx" +#include "android/Context.hxx" +#include "Main.hxx" #endif #ifndef WIN32 @@ -252,6 +254,18 @@ AllocatedPath GetUserMusicDir() #endif } +AllocatedPath +GetUserCacheDir() +{ +#ifdef USE_XDG + return GetUserDir("XDG_CACHE_DIR"); +#elif defined(ANDROID) + return context->GetCacheDir(Java::GetEnv()); +#else + return AllocatedPath::Null(); +#endif +} + #ifdef WIN32 AllocatedPath GetSystemConfigDir() diff --git a/src/fs/StandardDirectory.hxx b/src/fs/StandardDirectory.hxx index dca35b486..e3fba375a 100644 --- a/src/fs/StandardDirectory.hxx +++ b/src/fs/StandardDirectory.hxx @@ -33,6 +33,13 @@ AllocatedPath GetUserConfigDir(); */ AllocatedPath GetUserMusicDir(); +/** + * Obtains cache directory for the current user. + */ +gcc_pure +AllocatedPath +GetUserCacheDir(); + #ifdef WIN32 /** -- cgit v1.2.3