Use platform-specific user directory to store content. Create a file named portable.txt next to xenia.exe to restore previous behavior.

This commit is contained in:
gibbed
2018-11-21 18:04:43 -06:00
parent eb55d68e1f
commit 1ba5dd5eb1
9 changed files with 89 additions and 9 deletions

View File

@@ -12,11 +12,33 @@
#include <string>
#include <shlobj.h>
#include "xenia/base/platform_win.h"
namespace xe {
namespace filesystem {
std::wstring GetExecutablePath() {
wchar_t* path;
auto error = _get_wpgmptr(&path);
return !error ? std::wstring(path) : std::wstring();
}
std::wstring GetExecutableFolder() {
auto path = GetExecutablePath();
return xe::find_base_path(path);
}
std::wstring GetUserFolder() {
wchar_t path[MAX_PATH];
if (!SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_MYDOCUMENTS, nullptr,
SHGFP_TYPE_CURRENT, path))) {
return std::wstring();
}
return std::wstring(path);
}
bool PathExists(const std::wstring& path) {
DWORD attrib = GetFileAttributes(path.c_str());
return attrib != INVALID_FILE_ATTRIBUTES;