summaryrefslogtreecommitdiff
path: root/src/common/file_util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/file_util.cpp')
-rw-r--r--src/common/file_util.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 8a8ff3092..a1c12cbce 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -598,18 +598,12 @@ std::string& GetExeDirectory() {
598 return exe_path; 598 return exe_path;
599} 599}
600 600
601std::string& AppDataLocalDirectory() { 601std::string AppDataLocalDirectory() {
602 // Windows Vista or later only 602 PWSTR pw_local_path = nullptr;
603 static std::string local_path; 603 // Only supported by Windows Vista or later
604 if (local_path.empty()) { 604 SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &pw_local_path);
605 PWSTR pw_local_path = 0; 605 std::string local_path = Common::UTF16ToUTF8(pw_local_path);
606 wchar_t* wchar_local_path; 606 CoTaskMemFree(pw_local_path);
607 SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &pw_local_path);
608 wchar_local_path = pw_local_path;
609 local_path = Common::UTF16ToUTF8(wchar_local_path);
610 // Freeing memory
611 CoTaskMemFree(static_cast<void*>(pw_local_path));
612 }
613 return local_path; 607 return local_path;
614} 608}
615#else 609#else
@@ -691,7 +685,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string& new
691 paths[D_USER_IDX] = GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP; 685 paths[D_USER_IDX] = GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP;
692 if (!FileUtil::IsDirectory(paths[D_USER_IDX])) { 686 if (!FileUtil::IsDirectory(paths[D_USER_IDX])) {
693 paths[D_USER_IDX] = 687 paths[D_USER_IDX] =
694 AppDataLocalDirectory() + DIR_SEP + EMU_DATA_DIR DIR_SEP USERDATA_DIR DIR_SEP; 688 AppDataLocalDirectory() + DIR_SEP EMU_DATA_DIR DIR_SEP USERDATA_DIR DIR_SEP;
695 } 689 }
696 690
697 paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; 691 paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP;