summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/fs/path_util.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp
index 732c1559f..0abd81a45 100644
--- a/src/common/fs/path_util.cpp
+++ b/src/common/fs/path_util.cpp
@@ -6,7 +6,6 @@
6#include <unordered_map> 6#include <unordered_map>
7 7
8#include "common/fs/fs.h" 8#include "common/fs/fs.h"
9#include "common/string_util.h"
10#ifdef ANDROID 9#ifdef ANDROID
11#include "common/fs/fs_android.h" 10#include "common/fs/fs_android.h"
12#endif 11#endif
@@ -15,7 +14,7 @@
15#include "common/logging/log.h" 14#include "common/logging/log.h"
16 15
17#ifdef _WIN32 16#ifdef _WIN32
18#include <shlobj.h> // Used in GetExeDirectory() and GetWindowsDesktop() 17#include <shlobj.h> // Used in GetExeDirectory()
19#else 18#else
20#include <cstdlib> // Used in Get(Home/Data)Directory() 19#include <cstdlib> // Used in Get(Home/Data)Directory()
21#include <pwd.h> // Used in GetHomeDirectory() 20#include <pwd.h> // Used in GetHomeDirectory()
@@ -251,25 +250,30 @@ void SetYuzuPath(YuzuPath yuzu_path, const fs::path& new_path) {
251#ifdef _WIN32 250#ifdef _WIN32
252 251
253fs::path GetExeDirectory() { 252fs::path GetExeDirectory() {
254 WCHAR exe_path[MAX_PATH]; 253 wchar_t exe_path[MAX_PATH];
255 if (SUCCEEDED(GetModuleFileNameW(nullptr, exe_path, MAX_PATH))) { 254
256 std::wstring wide_exe_path(exe_path); 255 if (GetModuleFileNameW(nullptr, exe_path, MAX_PATH) == 0) {
257 return fs::path{Common::UTF16ToUTF8(wide_exe_path)}.parent_path(); 256 LOG_ERROR(Common_Filesystem,
257 "Failed to get the path to the executable of the current process");
258 } 258 }
259 LOG_ERROR(Common_Filesystem, "Failed to get the path to the executable of the current " 259
260 "process"); 260 return fs::path{exe_path}.parent_path();
261 return fs::path{};
262} 261}
263 262
264fs::path GetAppDataRoamingDirectory() { 263fs::path GetAppDataRoamingDirectory() {
265 PWSTR appdata_roaming_path = nullptr; 264 PWSTR appdata_roaming_path = nullptr;
266 if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &appdata_roaming_path))) { 265
267 std::wstring wide_appdata_roaming_path(appdata_roaming_path); 266 SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &appdata_roaming_path);
268 CoTaskMemFree(appdata_roaming_path); 267
269 return fs::path{Common::UTF16ToUTF8(wide_appdata_roaming_path)}; 268 auto fs_appdata_roaming_path = fs::path{appdata_roaming_path};
269
270 CoTaskMemFree(appdata_roaming_path);
271
272 if (fs_appdata_roaming_path.empty()) {
273 LOG_ERROR(Common_Filesystem, "Failed to get the path to the %APPDATA% directory");
270 } 274 }
271 LOG_ERROR(Common_Filesystem, "Failed to get the path to the %APPDATA% directory"); 275
272 return fs::path{}; 276 return fs_appdata_roaming_path;
273} 277}
274 278
275#else 279#else