aboutsummaryrefslogtreecommitdiffstats
path: root/src/Main.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-03-02 00:35:37 +0100
committerMax Kellermann <max@duempel.org>2014-03-02 00:35:37 +0100
commitd77c83f4bae775c89f5474a072996ab95c9cfa4c (patch)
treef39ac22116c056278a5e68c2a111a3d1a2a5be0a /src/Main.cxx
parent8cf3ac200b10cbab449b723d8b0f93cf94d479cf (diff)
downloadmpd-d77c83f4bae775c89f5474a072996ab95c9cfa4c.tar.gz
mpd-d77c83f4bae775c89f5474a072996ab95c9cfa4c.tar.xz
mpd-d77c83f4bae775c89f5474a072996ab95c9cfa4c.zip
Main: auto-configure state file on Android
Diffstat (limited to '')
-rw-r--r--src/Main.cxx17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/Main.cxx b/src/Main.cxx
index 3a6346385..79fc9d601 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -94,6 +94,7 @@
#include "java/File.hxx"
#include "android/Environment.hxx"
#include "android/Context.hxx"
+#include "fs/StandardDirectory.hxx"
#include "org_musicpd_Bridge.h"
#endif
@@ -262,8 +263,20 @@ static bool
glue_state_file_init(Error &error)
{
auto path_fs = config_get_path(CONF_STATE_FILE, error);
- if (path_fs.IsNull())
- return !error.IsDefined();
+ if (path_fs.IsNull()) {
+ if (error.IsDefined())
+ return false;
+
+#ifdef ANDROID
+ const auto cache_dir = GetUserCacheDir();
+ if (cache_dir.IsNull())
+ return true;
+
+ path_fs = AllocatedPath::Build(cache_dir, "state");
+#else
+ return true;
+#endif
+ }
state_file = new StateFile(std::move(path_fs),
*instance->partition,