aboutsummaryrefslogtreecommitdiff
path: root/src/common/fs/fs_android.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/fs/fs_android.h')
-rwxr-xr-xsrc/common/fs/fs_android.h58
1 files changed, 12 insertions, 46 deletions
diff --git a/src/common/fs/fs_android.h b/src/common/fs/fs_android.h
index 2c9234313..b33f4beb8 100755
--- a/src/common/fs/fs_android.h
+++ b/src/common/fs/fs_android.h
@@ -7,38 +7,17 @@
7#include <vector> 7#include <vector>
8#include <jni.h> 8#include <jni.h>
9 9
10#define ANDROID_STORAGE_FUNCTIONS(V) \
11 V(OpenContentUri, int, (const std::string& filepath, OpenMode openmode), open_content_uri, \
12 "openContentUri", "(Ljava/lang/String;Ljava/lang/String;)I")
13
14#define ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(V) \
15 V(GetSize, std::uint64_t, get_size, CallStaticLongMethod, "getSize", "(Ljava/lang/String;)J") \
16 V(IsDirectory, bool, is_directory, CallStaticBooleanMethod, "isDirectory", \
17 "(Ljava/lang/String;)Z") \
18 V(Exists, bool, file_exists, CallStaticBooleanMethod, "exists", "(Ljava/lang/String;)Z")
19
20#define ANDROID_SINGLE_PATH_HELPER_FUNCTIONS(V) \
21 V(GetParentDirectory, get_parent_directory, CallStaticObjectMethod, "getParentDirectory", \
22 "(Ljava/lang/String;)Ljava/lang/String;") \
23 V(GetFilename, get_filename, CallStaticObjectMethod, "getFilename", \
24 "(Ljava/lang/String;)Ljava/lang/String;")
25
26namespace Common::FS::Android { 10namespace Common::FS::Android {
27 11
28static JavaVM* g_jvm = nullptr; 12static JavaVM* g_jvm = nullptr;
29static jclass native_library = nullptr; 13static jclass native_library = nullptr;
30 14
31#define FH(FunctionName, JMethodID, Caller, JMethodName, Signature) F(JMethodID) 15static jmethodID s_get_parent_directory;
32#define FR(FunctionName, ReturnValue, JMethodID, Caller, JMethodName, Signature) F(JMethodID) 16static jmethodID s_get_filename;
33#define FS(FunctionName, ReturnValue, Parameters, JMethodID, JMethodName, Signature) F(JMethodID) 17static jmethodID s_get_size;
34#define F(JMethodID) static jmethodID JMethodID = nullptr; 18static jmethodID s_is_directory;
35ANDROID_SINGLE_PATH_HELPER_FUNCTIONS(FH) 19static jmethodID s_file_exists;
36ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR) 20static jmethodID s_open_content_uri;
37ANDROID_STORAGE_FUNCTIONS(FS)
38#undef F
39#undef FS
40#undef FR
41#undef FH
42 21
43enum class OpenMode { 22enum class OpenMode {
44 Read, 23 Read,
@@ -57,24 +36,11 @@ void UnRegisterCallbacks();
57 36
58bool IsContentUri(const std::string& path); 37bool IsContentUri(const std::string& path);
59 38
60#define FS(FunctionName, ReturnValue, Parameters, JMethodID, JMethodName, Signature) \ 39int OpenContentUri(const std::string& filepath, OpenMode openmode);
61 F(FunctionName, Parameters, ReturnValue) 40std::uint64_t GetSize(const std::string& filepath);
62#define F(FunctionName, Parameters, ReturnValue) ReturnValue FunctionName Parameters; 41bool IsDirectory(const std::string& filepath);
63ANDROID_STORAGE_FUNCTIONS(FS) 42bool Exists(const std::string& filepath);
64#undef F 43std::string GetParentDirectory(const std::string& filepath);
65#undef FS 44std::string GetFilename(const std::string& filepath);
66
67#define FR(FunctionName, ReturnValue, JMethodID, Caller, JMethodName, Signature) \
68 F(FunctionName, ReturnValue)
69#define F(FunctionName, ReturnValue) ReturnValue FunctionName(const std::string& filepath);
70ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR)
71#undef F
72#undef FR
73
74#define FH(FunctionName, JMethodID, Caller, JMethodName, Signature) F(FunctionName)
75#define F(FunctionName) std::string FunctionName(const std::string& filepath);
76ANDROID_SINGLE_PATH_HELPER_FUNCTIONS(FH)
77#undef F
78#undef FH
79 45
80} // namespace Common::FS::Android 46} // namespace Common::FS::Android