diff options
Diffstat (limited to 'src/common/fs/fs_android.h')
-rwxr-xr-x | src/common/fs/fs_android.h | 58 |
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 | |||
26 | namespace Common::FS::Android { | 10 | namespace Common::FS::Android { |
27 | 11 | ||
28 | static JavaVM* g_jvm = nullptr; | 12 | static JavaVM* g_jvm = nullptr; |
29 | static jclass native_library = nullptr; | 13 | static jclass native_library = nullptr; |
30 | 14 | ||
31 | #define FH(FunctionName, JMethodID, Caller, JMethodName, Signature) F(JMethodID) | 15 | static jmethodID s_get_parent_directory; |
32 | #define FR(FunctionName, ReturnValue, JMethodID, Caller, JMethodName, Signature) F(JMethodID) | 16 | static jmethodID s_get_filename; |
33 | #define FS(FunctionName, ReturnValue, Parameters, JMethodID, JMethodName, Signature) F(JMethodID) | 17 | static jmethodID s_get_size; |
34 | #define F(JMethodID) static jmethodID JMethodID = nullptr; | 18 | static jmethodID s_is_directory; |
35 | ANDROID_SINGLE_PATH_HELPER_FUNCTIONS(FH) | 19 | static jmethodID s_file_exists; |
36 | ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(FR) | 20 | static jmethodID s_open_content_uri; |
37 | ANDROID_STORAGE_FUNCTIONS(FS) | ||
38 | #undef F | ||
39 | #undef FS | ||
40 | #undef FR | ||
41 | #undef FH | ||
42 | 21 | ||
43 | enum class OpenMode { | 22 | enum class OpenMode { |
44 | Read, | 23 | Read, |
@@ -57,24 +36,11 @@ void UnRegisterCallbacks(); | |||
57 | 36 | ||
58 | bool IsContentUri(const std::string& path); | 37 | bool IsContentUri(const std::string& path); |
59 | 38 | ||
60 | #define FS(FunctionName, ReturnValue, Parameters, JMethodID, JMethodName, Signature) \ | 39 | int OpenContentUri(const std::string& filepath, OpenMode openmode); |
61 | F(FunctionName, Parameters, ReturnValue) | 40 | std::uint64_t GetSize(const std::string& filepath); |
62 | #define F(FunctionName, Parameters, ReturnValue) ReturnValue FunctionName Parameters; | 41 | bool IsDirectory(const std::string& filepath); |
63 | ANDROID_STORAGE_FUNCTIONS(FS) | 42 | bool Exists(const std::string& filepath); |
64 | #undef F | 43 | std::string GetParentDirectory(const std::string& filepath); |
65 | #undef FS | 44 | std::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); | ||
70 | ANDROID_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); | ||
76 | ANDROID_SINGLE_PATH_HELPER_FUNCTIONS(FH) | ||
77 | #undef F | ||
78 | #undef FH | ||
79 | 45 | ||
80 | } // namespace Common::FS::Android | 46 | } // namespace Common::FS::Android |