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:
@@ -20,6 +20,15 @@
|
||||
namespace xe {
|
||||
namespace filesystem {
|
||||
|
||||
// Get executable path.
|
||||
std::wstring GetExecutablePath();
|
||||
|
||||
// Get executable folder.
|
||||
std::wstring GetExecutableFolder();
|
||||
|
||||
// Get user folder.
|
||||
std::wstring GetUserFolder();
|
||||
|
||||
// Canonicalizes a path, removing ..'s.
|
||||
std::string CanonicalizePath(const std::string& original_path);
|
||||
|
||||
|
||||
@@ -21,6 +21,21 @@
|
||||
namespace xe {
|
||||
namespace filesystem {
|
||||
|
||||
std::wstring GetExecutablePath() {
|
||||
assert_always(); // IMPLEMENT ME.
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
std::wstring GetExecutableFolder() {
|
||||
assert_always(); // IMPLEMENT ME.
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
std::wstring GetUserFolder() {
|
||||
assert_always(); // IMPLEMENT ME.
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
bool PathExists(const std::wstring& path) {
|
||||
struct stat st;
|
||||
return stat(xe::to_string(path).c_str(), &st) == 0;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user