summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt18
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt5
-rw-r--r--src/common/fs/fs.cpp27
-rw-r--r--src/common/fs/fs_android.h5
4 files changed, 54 insertions, 1 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt
index 22f0a2646..f3bfbe7eb 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt
@@ -19,6 +19,8 @@ import org.yuzu.yuzu_emu.activities.EmulationActivity
19import org.yuzu.yuzu_emu.utils.DocumentsTree.Companion.isNativePath 19import org.yuzu.yuzu_emu.utils.DocumentsTree.Companion.isNativePath
20import org.yuzu.yuzu_emu.utils.FileUtil.getFileSize 20import org.yuzu.yuzu_emu.utils.FileUtil.getFileSize
21import org.yuzu.yuzu_emu.utils.FileUtil.openContentUri 21import org.yuzu.yuzu_emu.utils.FileUtil.openContentUri
22import org.yuzu.yuzu_emu.utils.FileUtil.exists
23import org.yuzu.yuzu_emu.utils.FileUtil.isDirectory
22import org.yuzu.yuzu_emu.utils.Log.error 24import org.yuzu.yuzu_emu.utils.Log.error
23import org.yuzu.yuzu_emu.utils.Log.verbose 25import org.yuzu.yuzu_emu.utils.Log.verbose
24import org.yuzu.yuzu_emu.utils.Log.warning 26import org.yuzu.yuzu_emu.utils.Log.warning
@@ -85,6 +87,22 @@ object NativeLibrary {
85 } else getFileSize(appContext, path) 87 } else getFileSize(appContext, path)
86 } 88 }
87 89
90 @Keep
91 @JvmStatic
92 fun exists(path: String?): Boolean {
93 return if (isNativePath(path!!)) {
94 YuzuApplication.documentsTree!!.exists(path)
95 } else exists(appContext, path)
96 }
97
98 @Keep
99 @JvmStatic
100 fun isDirectory(path: String?): Boolean {
101 return if (isNativePath(path!!)) {
102 YuzuApplication.documentsTree!!.isDirectory(path)
103 } else isDirectory(appContext, path)
104 }
105
88 /** 106 /**
89 * Returns true if pro controller isn't available and handheld is 107 * Returns true if pro controller isn't available and handheld is
90 */ 108 */
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt
index cc8ea6b9d..f8abae445 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/DocumentsTree.kt
@@ -36,6 +36,11 @@ class DocumentsTree {
36 return resolvePath(filepath) != null 36 return resolvePath(filepath) != null
37 } 37 }
38 38
39 fun isDirectory(filepath: String): Boolean {
40 val node = resolvePath(filepath)
41 return node != null && node.isDirectory
42 }
43
39 private fun resolvePath(filepath: String): DocumentsNode? { 44 private fun resolvePath(filepath: String): DocumentsNode? {
40 val tokens = StringTokenizer(filepath, File.separator, false) 45 val tokens = StringTokenizer(filepath, File.separator, false)
41 var iterator = root 46 var iterator = root
diff --git a/src/common/fs/fs.cpp b/src/common/fs/fs.cpp
index e1716c62d..6d66c926d 100644
--- a/src/common/fs/fs.cpp
+++ b/src/common/fs/fs.cpp
@@ -3,6 +3,9 @@
3 3
4#include "common/fs/file.h" 4#include "common/fs/file.h"
5#include "common/fs/fs.h" 5#include "common/fs/fs.h"
6#ifdef ANDROID
7#include "common/fs/fs_android.h"
8#endif
6#include "common/fs/path_util.h" 9#include "common/fs/path_util.h"
7#include "common/logging/log.h" 10#include "common/logging/log.h"
8 11
@@ -525,15 +528,39 @@ void IterateDirEntriesRecursively(const std::filesystem::path& path,
525// Generic Filesystem Operations 528// Generic Filesystem Operations
526 529
527bool Exists(const fs::path& path) { 530bool Exists(const fs::path& path) {
531#ifdef ANDROID
532 if (Android::IsContentUri(path)) {
533 return Android::Exists(path);
534 } else {
535 return fs::exists(path);
536 }
537#else
528 return fs::exists(path); 538 return fs::exists(path);
539#endif
529} 540}
530 541
531bool IsFile(const fs::path& path) { 542bool IsFile(const fs::path& path) {
543#ifdef ANDROID
544 if (Android::IsContentUri(path)) {
545 return !Android::IsDirectory(path);
546 } else {
547 return fs::is_regular_file(path);
548 }
549#else
532 return fs::is_regular_file(path); 550 return fs::is_regular_file(path);
551#endif
533} 552}
534 553
535bool IsDir(const fs::path& path) { 554bool IsDir(const fs::path& path) {
555#ifdef ANDROID
556 if (Android::IsContentUri(path)) {
557 return Android::IsDirectory(path);
558 } else {
559 return fs::is_directory(path);
560 }
561#else
536 return fs::is_directory(path); 562 return fs::is_directory(path);
563#endif
537} 564}
538 565
539fs::path GetCurrentDir() { 566fs::path GetCurrentDir() {
diff --git a/src/common/fs/fs_android.h b/src/common/fs/fs_android.h
index bb8a52648..b441c2a12 100644
--- a/src/common/fs/fs_android.h
+++ b/src/common/fs/fs_android.h
@@ -12,7 +12,10 @@
12 "openContentUri", "(Ljava/lang/String;Ljava/lang/String;)I") 12 "openContentUri", "(Ljava/lang/String;Ljava/lang/String;)I")
13 13
14#define ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(V) \ 14#define ANDROID_SINGLE_PATH_DETERMINE_FUNCTIONS(V) \
15 V(GetSize, std::uint64_t, get_size, CallStaticLongMethod, "getSize", "(Ljava/lang/String;)J") 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")
16 19
17namespace Common::FS::Android { 20namespace Common::FS::Android {
18 21