Android: obtain music directory from Environment.getExternalStoragePublicDirectory()

This commit is contained in:
Max Kellermann
2014-03-01 17:46:59 +01:00
parent 1e06c66c77
commit 58771fc41c
5 changed files with 184 additions and 2 deletions

View File

@@ -20,7 +20,7 @@
#include "config.h"
// Use X Desktop guidelines where applicable
#if !defined(__APPLE__) && !defined(WIN32)
#if !defined(__APPLE__) && !defined(WIN32) && !defined(ANDROID)
#define USE_XDG
#endif
@@ -47,6 +47,11 @@
#include <utility>
#endif
#ifdef ANDROID
#include "java/Global.hxx"
#include "android/Environment.hxx"
#endif
#ifndef WIN32
class PasswdEntry
{
@@ -240,6 +245,14 @@ AllocatedPath GetUserMusicDir()
return GetStandardDir(CSIDL_MYMUSIC);
#elif defined(USE_XDG)
return GetUserDir("XDG_MUSIC_DIR");
#elif defined(ANDROID)
char buffer[1024];
if (Environment::getExternalStoragePublicDirectory(buffer,
sizeof(buffer),
"Music") == nullptr)
return AllocatedPath::Null();
return AllocatedPath::FromUTF8(buffer);
#else
return AllocatedPath::Null();
#endif