Android/Context: allow type=nullptr in GetExternalFilesDir()

This commit is contained in:
Max Kellermann 2022-08-18 16:49:02 +02:00
parent 1aa3c1e543
commit 5d0d5b5d97
2 changed files with 7 additions and 5 deletions

View File

@ -44,13 +44,12 @@ Context::Initialise(JNIEnv *env) noexcept
}
AllocatedPath
Context::GetExternalFilesDir(JNIEnv *env, const char *_type) noexcept
Context::GetExternalFilesDir(JNIEnv *env, const char *type) noexcept
{
assert(_type != nullptr);
Java::String type{env, _type};
jobject file = env->CallObjectMethod(Get(), getExternalFilesDir_method, type.Get());
jobject file = env->CallObjectMethod(Get(), getExternalFilesDir_method,
Java::String::Optional(env, type).Get());
if (Java::DiscardException(env) || file == nullptr)
return nullptr;

View File

@ -36,9 +36,12 @@ public:
Context(JNIEnv *env, jobject obj) noexcept
:Java::GlobalObject(env, obj) {}
/**
* @param type the subdirectory name; may be nullptr
*/
[[gnu::pure]]
AllocatedPath GetExternalFilesDir(JNIEnv *env,
const char *type) noexcept;
const char *type=nullptr) noexcept;
[[gnu::pure]]
AllocatedPath GetCacheDir(JNIEnv *env) const noexcept;