mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-08-16 23:37:41 -05:00
Common/FileSearch: Refactor DoFileSearch
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <ios>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
@@ -14,22 +15,34 @@ std::string GetJString(JNIEnv* env, jstring jstr);
|
||||
jstring ToJString(JNIEnv* env, std::string_view str);
|
||||
|
||||
std::vector<std::string> JStringArrayToVector(JNIEnv* env, jobjectArray array);
|
||||
jobjectArray VectorToJStringArray(JNIEnv* env, const std::vector<std::string>& vector);
|
||||
jobjectArray SpanToJStringArray(JNIEnv* env, std::span<const std::string_view> span);
|
||||
jobjectArray SpanToJStringArray(JNIEnv* env, std::span<const std::string> span);
|
||||
inline jobjectArray VectorToJStringArray(JNIEnv* env, const std::vector<std::string>& vector)
|
||||
{
|
||||
return SpanToJStringArray(env, vector);
|
||||
}
|
||||
|
||||
template <typename T, typename F>
|
||||
jobjectArray VectorToJObjectArray(JNIEnv* env, const std::vector<T>& vector, jclass clazz, F f)
|
||||
jobjectArray SpanToJObjectArray(JNIEnv* env, std::span<const T> span, jclass clazz, F f)
|
||||
{
|
||||
const auto vector_size = static_cast<jsize>(vector.size());
|
||||
jobjectArray result = env->NewObjectArray(vector_size, clazz, nullptr);
|
||||
for (jsize i = 0; i < vector_size; ++i)
|
||||
const auto span_size = static_cast<jsize>(span.size());
|
||||
jobjectArray result = env->NewObjectArray(span_size, clazz, nullptr);
|
||||
for (jsize i = 0; i < span_size; ++i)
|
||||
{
|
||||
jobject obj = f(env, vector[i]);
|
||||
jobject obj = f(env, span[i]);
|
||||
env->SetObjectArrayElement(result, i, obj);
|
||||
env->DeleteLocalRef(obj);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T, typename F>
|
||||
inline jobjectArray VectorToJObjectArray(JNIEnv* env, const std::vector<T>& vector, jclass clazz,
|
||||
F f)
|
||||
{
|
||||
return SpanToJObjectArray(env, std::span(vector), clazz, f);
|
||||
}
|
||||
|
||||
// Returns true if the given path should be opened as Android content instead of a normal file.
|
||||
bool IsPathAndroidContent(std::string_view uri);
|
||||
|
||||
@@ -55,7 +68,7 @@ std::string GetAndroidContentDisplayName(std::string_view uri);
|
||||
std::vector<std::string> GetAndroidContentChildNames(std::string_view uri);
|
||||
|
||||
std::vector<std::string> DoFileSearchAndroidContent(std::string_view directory,
|
||||
const std::vector<std::string>& extensions,
|
||||
std::span<const std::string_view> extensions,
|
||||
bool recursive);
|
||||
|
||||
int GetNetworkIpAddress();
|
||||
|
||||
Reference in New Issue
Block a user