diff options
Diffstat (limited to 'src/common/fs/path_util.cpp')
| -rw-r--r-- | src/common/fs/path_util.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp index defa3e918..d71cfacc6 100644 --- a/src/common/fs/path_util.cpp +++ b/src/common/fs/path_util.cpp | |||
| @@ -6,6 +6,9 @@ | |||
| 6 | #include <unordered_map> | 6 | #include <unordered_map> |
| 7 | 7 | ||
| 8 | #include "common/fs/fs.h" | 8 | #include "common/fs/fs.h" |
| 9 | #ifdef ANDROID | ||
| 10 | #include "common/fs/fs_android.h" | ||
| 11 | #endif | ||
| 9 | #include "common/fs/fs_paths.h" | 12 | #include "common/fs/fs_paths.h" |
| 10 | #include "common/fs/path_util.h" | 13 | #include "common/fs/path_util.h" |
| 11 | #include "common/logging/log.h" | 14 | #include "common/logging/log.h" |
| @@ -80,9 +83,7 @@ public: | |||
| 80 | yuzu_paths.insert_or_assign(yuzu_path, new_path); | 83 | yuzu_paths.insert_or_assign(yuzu_path, new_path); |
| 81 | } | 84 | } |
| 82 | 85 | ||
| 83 | private: | 86 | void Reinitialize(fs::path yuzu_path = {}) { |
| 84 | PathManagerImpl() { | ||
| 85 | fs::path yuzu_path; | ||
| 86 | fs::path yuzu_path_cache; | 87 | fs::path yuzu_path_cache; |
| 87 | fs::path yuzu_path_config; | 88 | fs::path yuzu_path_config; |
| 88 | 89 | ||
| @@ -95,6 +96,10 @@ private: | |||
| 95 | 96 | ||
| 96 | yuzu_path_cache = yuzu_path / CACHE_DIR; | 97 | yuzu_path_cache = yuzu_path / CACHE_DIR; |
| 97 | yuzu_path_config = yuzu_path / CONFIG_DIR; | 98 | yuzu_path_config = yuzu_path / CONFIG_DIR; |
| 99 | #elif ANDROID | ||
| 100 | ASSERT(!yuzu_path.empty()); | ||
| 101 | yuzu_path_cache = yuzu_path / CACHE_DIR; | ||
| 102 | yuzu_path_config = yuzu_path / CONFIG_DIR; | ||
| 98 | #else | 103 | #else |
| 99 | yuzu_path = GetCurrentDir() / PORTABLE_DIR; | 104 | yuzu_path = GetCurrentDir() / PORTABLE_DIR; |
| 100 | 105 | ||
| @@ -109,6 +114,7 @@ private: | |||
| 109 | #endif | 114 | #endif |
| 110 | 115 | ||
| 111 | GenerateYuzuPath(YuzuPath::YuzuDir, yuzu_path); | 116 | GenerateYuzuPath(YuzuPath::YuzuDir, yuzu_path); |
| 117 | GenerateYuzuPath(YuzuPath::AmiiboDir, yuzu_path / AMIIBO_DIR); | ||
| 112 | GenerateYuzuPath(YuzuPath::CacheDir, yuzu_path_cache); | 118 | GenerateYuzuPath(YuzuPath::CacheDir, yuzu_path_cache); |
| 113 | GenerateYuzuPath(YuzuPath::ConfigDir, yuzu_path_config); | 119 | GenerateYuzuPath(YuzuPath::ConfigDir, yuzu_path_config); |
| 114 | GenerateYuzuPath(YuzuPath::DumpDir, yuzu_path / DUMP_DIR); | 120 | GenerateYuzuPath(YuzuPath::DumpDir, yuzu_path / DUMP_DIR); |
| @@ -122,6 +128,11 @@ private: | |||
| 122 | GenerateYuzuPath(YuzuPath::TASDir, yuzu_path / TAS_DIR); | 128 | GenerateYuzuPath(YuzuPath::TASDir, yuzu_path / TAS_DIR); |
| 123 | } | 129 | } |
| 124 | 130 | ||
| 131 | private: | ||
| 132 | PathManagerImpl() { | ||
| 133 | Reinitialize(); | ||
| 134 | } | ||
| 135 | |||
| 125 | ~PathManagerImpl() = default; | 136 | ~PathManagerImpl() = default; |
| 126 | 137 | ||
| 127 | void GenerateYuzuPath(YuzuPath yuzu_path, const fs::path& new_path) { | 138 | void GenerateYuzuPath(YuzuPath yuzu_path, const fs::path& new_path) { |
| @@ -210,6 +221,10 @@ fs::path RemoveTrailingSeparators(const fs::path& path) { | |||
| 210 | return fs::path{string_path}; | 221 | return fs::path{string_path}; |
| 211 | } | 222 | } |
| 212 | 223 | ||
| 224 | void SetAppDirectory(const std::string& app_directory) { | ||
| 225 | PathManagerImpl::GetInstance().Reinitialize(app_directory); | ||
| 226 | } | ||
| 227 | |||
| 213 | const fs::path& GetYuzuPath(YuzuPath yuzu_path) { | 228 | const fs::path& GetYuzuPath(YuzuPath yuzu_path) { |
| 214 | return PathManagerImpl::GetInstance().GetYuzuPathImpl(yuzu_path); | 229 | return PathManagerImpl::GetInstance().GetYuzuPathImpl(yuzu_path); |
| 215 | } | 230 | } |
| @@ -350,6 +365,12 @@ std::vector<std::string> SplitPathComponents(std::string_view filename) { | |||
| 350 | 365 | ||
| 351 | std::string SanitizePath(std::string_view path_, DirectorySeparator directory_separator) { | 366 | std::string SanitizePath(std::string_view path_, DirectorySeparator directory_separator) { |
| 352 | std::string path(path_); | 367 | std::string path(path_); |
| 368 | #ifdef ANDROID | ||
| 369 | if (Android::IsContentUri(path)) { | ||
| 370 | return path; | ||
| 371 | } | ||
| 372 | #endif // ANDROID | ||
| 373 | |||
| 353 | char type1 = directory_separator == DirectorySeparator::BackwardSlash ? '/' : '\\'; | 374 | char type1 = directory_separator == DirectorySeparator::BackwardSlash ? '/' : '\\'; |
| 354 | char type2 = directory_separator == DirectorySeparator::BackwardSlash ? '\\' : '/'; | 375 | char type2 = directory_separator == DirectorySeparator::BackwardSlash ? '\\' : '/'; |
| 355 | 376 | ||