diff options
author | bunnei <bunneidev@gmail.com> | 2023-02-03 16:13:16 -0800 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2023-06-03 00:05:29 -0700 |
commit | ef605f7d8f8241b95b977d95cf5247c1f2d8a309 (patch) | |
tree | 7e9dcc62168e23115d05119a5854d59544c89b8d /src/common/fs/path_util.cpp | |
parent | 39ab81a098a28a229b254f6ff82e0a02c9de5c81 (diff) |
android: Implement SAF support & migrate to SDK 31. (#4)
Diffstat (limited to 'src/common/fs/path_util.cpp')
-rw-r--r-- | src/common/fs/path_util.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp index ca755b053..e026a13d9 100644 --- a/src/common/fs/path_util.cpp +++ b/src/common/fs/path_util.cpp @@ -6,6 +6,9 @@ #include <unordered_map> #include "common/fs/fs.h" +#ifdef ANDROID +#include "common/fs/fs_android.h" +#endif #include "common/fs/fs_paths.h" #include "common/fs/path_util.h" #include "common/logging/log.h" @@ -80,9 +83,7 @@ public: yuzu_paths.insert_or_assign(yuzu_path, new_path); } -private: - PathManagerImpl() { - fs::path yuzu_path; + void Reinitialize(fs::path yuzu_path = {}) { fs::path yuzu_path_cache; fs::path yuzu_path_config; @@ -96,12 +97,9 @@ private: yuzu_path_cache = yuzu_path / CACHE_DIR; yuzu_path_config = yuzu_path / CONFIG_DIR; #elif ANDROID - // On Android internal storage is mounted as "/sdcard" - if (Exists("/sdcard")) { - yuzu_path = "/sdcard/yuzu-emu"; - yuzu_path_cache = yuzu_path / CACHE_DIR; - yuzu_path_config = yuzu_path / CONFIG_DIR; - } + ASSERT(!yuzu_path.empty()); + yuzu_path_cache = yuzu_path / CACHE_DIR; + yuzu_path_config = yuzu_path / CONFIG_DIR; #else yuzu_path = GetCurrentDir() / PORTABLE_DIR; @@ -129,6 +127,11 @@ private: GenerateYuzuPath(YuzuPath::TASDir, yuzu_path / TAS_DIR); } +private: + PathManagerImpl() { + Reinitialize(); + } + ~PathManagerImpl() = default; void GenerateYuzuPath(YuzuPath yuzu_path, const fs::path& new_path) { @@ -217,6 +220,10 @@ fs::path RemoveTrailingSeparators(const fs::path& path) { return fs::path{string_path}; } +void SetAppDirectory(const std::string& app_directory) { + PathManagerImpl::GetInstance().Reinitialize(app_directory); +} + const fs::path& GetYuzuPath(YuzuPath yuzu_path) { return PathManagerImpl::GetInstance().GetYuzuPathImpl(yuzu_path); } @@ -357,6 +364,12 @@ std::vector<std::string> SplitPathComponents(std::string_view filename) { std::string SanitizePath(std::string_view path_, DirectorySeparator directory_separator) { std::string path(path_); +#ifdef ANDROID + if (Android::IsContentUri(path)) { + return path; + } +#endif // ANDROID + char type1 = directory_separator == DirectorySeparator::BackwardSlash ? '/' : '\\'; char type2 = directory_separator == DirectorySeparator::BackwardSlash ? '\\' : '/'; |