Commit 2dba06dc authored by Max Kellermann's avatar Max Kellermann

android/Context: add GetExternalFilesDir()

parent 811860c3
......@@ -27,6 +27,25 @@
#include "AudioManager.hxx"
AllocatedPath
Context::GetExternalFilesDir(JNIEnv *env, const char *_type) noexcept
{
assert(_type != nullptr);
Java::Class cls{env, env->GetObjectClass(Get())};
jmethodID method = env->GetMethodID(cls, "getExternalFilesDir",
"(Ljava/lang/String;)Ljava/io/File;");
assert(method);
Java::String type{env, _type};
jobject file = env->CallObjectMethod(Get(), method, type.Get());
if (Java::DiscardException(env) || file == nullptr)
return nullptr;
return Java::File::ToAbsolutePath(env, file);
}
AllocatedPath
Context::GetCacheDir(JNIEnv *env) const noexcept
{
assert(env != nullptr);
......
......@@ -31,6 +31,10 @@ public:
:Java::GlobalObject(env, obj) {}
[[gnu::pure]]
AllocatedPath GetExternalFilesDir(JNIEnv *env,
const char *type) noexcept;
[[gnu::pure]]
AllocatedPath GetCacheDir(JNIEnv *env) const noexcept;
[[gnu::pure]]
......
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