diff options
author | freiro <freiro@users.noreply.github.com> | 2016-11-17 01:33:16 +0100 |
---|---|---|
committer | freiro <f73b2894@opayq.com> | 2016-11-19 15:49:52 +0100 |
commit | 29bb82cb8e5c34eba174964099b2cdc04103de7b (patch) | |
tree | b724d316ea32df337bd4137a1e985481dc7f013c /src | |
parent | Merge pull request #2172 from jroweboy/fix-mingw (diff) | |
download | yuzu-29bb82cb8e5c34eba174964099b2cdc04103de7b.tar yuzu-29bb82cb8e5c34eba174964099b2cdc04103de7b.tar.gz yuzu-29bb82cb8e5c34eba174964099b2cdc04103de7b.tar.bz2 yuzu-29bb82cb8e5c34eba174964099b2cdc04103de7b.tar.lz yuzu-29bb82cb8e5c34eba174964099b2cdc04103de7b.tar.xz yuzu-29bb82cb8e5c34eba174964099b2cdc04103de7b.tar.zst yuzu-29bb82cb8e5c34eba174964099b2cdc04103de7b.zip |
Diffstat (limited to '')
-rw-r--r-- | src/common/file_util.cpp | 23 | ||||
-rw-r--r-- | src/common/file_util.h | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 407ed047a..8a8ff3092 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -26,6 +26,9 @@ #define stat _stat64 #define fstat _fstat64 #define fileno _fileno +// Windows version, at least Vista is required to obtain AppData Path +#define WINVER 0x0600 +#define _WIN32_WINNT 0x0600 #else #ifdef __APPLE__ #include <sys/param.h> @@ -594,6 +597,21 @@ std::string& GetExeDirectory() { } return exe_path; } + +std::string& AppDataLocalDirectory() { + // Windows Vista or later only + static std::string local_path; + if (local_path.empty()) { + PWSTR pw_local_path = 0; + wchar_t* wchar_local_path; + SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &pw_local_path); + wchar_local_path = pw_local_path; + local_path = Common::UTF16ToUTF8(wchar_local_path); + // Freeing memory + CoTaskMemFree(static_cast<void*>(pw_local_path)); + } + return local_path; +} #else /** * @return The user’s home directory on POSIX systems @@ -671,6 +689,11 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string& new if (paths[D_USER_IDX].empty()) { #ifdef _WIN32 paths[D_USER_IDX] = GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP; + if (!FileUtil::IsDirectory(paths[D_USER_IDX])) { + paths[D_USER_IDX] = + AppDataLocalDirectory() + DIR_SEP + EMU_DATA_DIR DIR_SEP USERDATA_DIR DIR_SEP; + } + paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; paths[D_CACHE_IDX] = paths[D_USER_IDX] + CACHE_DIR DIR_SEP; #else diff --git a/src/common/file_util.h b/src/common/file_util.h index 204b06f14..03cb222fe 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -154,6 +154,7 @@ std::string GetBundleDirectory(); #ifdef _WIN32 std::string& GetExeDirectory(); +std::string& AppDataLocalDirectory(); #endif size_t WriteStringToFile(bool text_file, const std::string& str, const char* filename); |