summaryrefslogtreecommitdiff
path: root/src/common/fs/path_util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/fs/path_util.cpp')
-rw-r--r--src/common/fs/path_util.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp
index defa3e918..e026a13d9 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
83private: 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
@@ -122,6 +127,11 @@ private:
122 GenerateYuzuPath(YuzuPath::TASDir, yuzu_path / TAS_DIR); 127 GenerateYuzuPath(YuzuPath::TASDir, yuzu_path / TAS_DIR);
123 } 128 }
124 129
130private:
131 PathManagerImpl() {
132 Reinitialize();
133 }
134
125 ~PathManagerImpl() = default; 135 ~PathManagerImpl() = default;
126 136
127 void GenerateYuzuPath(YuzuPath yuzu_path, const fs::path& new_path) { 137 void GenerateYuzuPath(YuzuPath yuzu_path, const fs::path& new_path) {
@@ -210,6 +220,10 @@ fs::path RemoveTrailingSeparators(const fs::path& path) {
210 return fs::path{string_path}; 220 return fs::path{string_path};
211} 221}
212 222
223void SetAppDirectory(const std::string& app_directory) {
224 PathManagerImpl::GetInstance().Reinitialize(app_directory);
225}
226
213const fs::path& GetYuzuPath(YuzuPath yuzu_path) { 227const fs::path& GetYuzuPath(YuzuPath yuzu_path) {
214 return PathManagerImpl::GetInstance().GetYuzuPathImpl(yuzu_path); 228 return PathManagerImpl::GetInstance().GetYuzuPathImpl(yuzu_path);
215} 229}
@@ -350,6 +364,12 @@ std::vector<std::string> SplitPathComponents(std::string_view filename) {
350 364
351std::string SanitizePath(std::string_view path_, DirectorySeparator directory_separator) { 365std::string SanitizePath(std::string_view path_, DirectorySeparator directory_separator) {
352 std::string path(path_); 366 std::string path(path_);
367#ifdef ANDROID
368 if (Android::IsContentUri(path)) {
369 return path;
370 }
371#endif // ANDROID
372
353 char type1 = directory_separator == DirectorySeparator::BackwardSlash ? '/' : '\\'; 373 char type1 = directory_separator == DirectorySeparator::BackwardSlash ? '/' : '\\';
354 char type2 = directory_separator == DirectorySeparator::BackwardSlash ? '\\' : '/'; 374 char type2 = directory_separator == DirectorySeparator::BackwardSlash ? '\\' : '/';
355 375