diff options
author | bunnei <bunneidev@gmail.com> | 2023-06-05 21:43:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-05 21:43:43 -0700 |
commit | cb95d7fe1b6d81899fe6b279400da2c991e3132c (patch) | |
tree | a856ac45b1053009c4c11ee141c49d7faa4c8a19 /src/common/fs/fs_android.h | |
parent | db7b106f1d9d559dadfd9ed070a8b0986609ec57 (diff) | |
parent | 036996429e1766231c5002bb333ee4e67d216c2c (diff) |
Merge pull request #10508 from yuzu-emu/lime
Project Lime - yuzu Android Port
Diffstat (limited to 'src/common/fs/fs_android.h')
-rw-r--r-- | src/common/fs/fs_android.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/common/fs/fs_android.h b/src/common/fs/fs_android.h new file mode 100644 index 000000000..bb8a52648 --- /dev/null +++ b/src/common/fs/fs_android.h @@ -0,0 +1,62 @@ +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <string> +#include <vector> +#include <jni.h> + +#define ANDROID_STORAGE_FUNCTIONS(V) \ + V(OpenContentUri, int, (const std::string& filepath, OpenMode openmode), open_content_uri, \ + "openContentUri", "(Ljava/lang/String;Ljava/lang/String;)I") + +#define ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(V) \ + V(GetSize, std::uint64_t, get_size, CallStaticLongMethod, "getSize", "(Ljava/lang/String;)J") + +namespace Common::FS::Android { + +static JavaVM* g_jvm = nullptr; +static jclass native_library = nullptr; + +#define FR(FunctionName, ReturnValue, JMethodID, Caller, JMethodName, Signature) F(JMethodID) +#define FS(FunctionName, ReturnValue, Parameters, JMethodID, JMethodName, Signature) F(JMethodID) +#define F(JMethodID) static jmethodID JMethodID = nullptr; +ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR) +ANDROID_STORAGE_FUNCTIONS(FS) +#undef F +#undef FS +#undef FR + +enum class OpenMode { + Read, + Write, + ReadWrite, + WriteAppend, + WriteTruncate, + ReadWriteAppend, + ReadWriteTruncate, + Never +}; + +void RegisterCallbacks(JNIEnv* env, jclass clazz); + +void UnRegisterCallbacks(); + +bool IsContentUri(const std::string& path); + +#define FS(FunctionName, ReturnValue, Parameters, JMethodID, JMethodName, Signature) \ + F(FunctionName, Parameters, ReturnValue) +#define F(FunctionName, Parameters, ReturnValue) ReturnValue FunctionName Parameters; +ANDROID_STORAGE_FUNCTIONS(FS) +#undef F +#undef FS + +#define FR(FunctionName, ReturnValue, JMethodID, Caller, JMethodName, Signature) \ + F(FunctionName, ReturnValue) +#define F(FunctionName, ReturnValue) ReturnValue FunctionName(const std::string& filepath); +ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR) +#undef F +#undef FR + +} // namespace Common::FS::Android |