diff --git a/src/xenia/app/xenia_main.cc b/src/xenia/app/xenia_main.cc index 2597fc02f..090b6e9ed 100644 --- a/src/xenia/app/xenia_main.cc +++ b/src/xenia/app/xenia_main.cc @@ -154,7 +154,7 @@ int xenia_main(const std::vector& args) { #if defined(XE_PLATFORM_WIN32) content_root = xe::join_paths(content_root, L"Xenia"); #elif defined(XE_PLATFORM_LINUX) - content_root = xe::join_paths(content_root, L".xenia"); + content_root = xe::join_paths(content_root, L"Xenia"); #else #warning Unhandled platform for content root. content_root = xe::join_paths(content_root, L"Xenia"); diff --git a/src/xenia/base/filesystem_posix.cc b/src/xenia/base/filesystem_posix.cc index 2e81f5089..caf8219ad 100644 --- a/src/xenia/base/filesystem_posix.cc +++ b/src/xenia/base/filesystem_posix.cc @@ -12,29 +12,58 @@ #include "xenia/base/logging.h" #include "xenia/base/string.h" +#include #include #include #include +#include +#include +#include +#include #include #include #include +#include namespace xe { namespace filesystem { std::wstring GetExecutablePath() { - assert_always(); // IMPLEMENT ME. - return std::wstring(); + char buff[FILENAME_MAX] = ""; + readlink("/proc/self/exe", buff, FILENAME_MAX); + std::string s(buff); + return to_wstring(s); } std::wstring GetExecutableFolder() { - assert_always(); // IMPLEMENT ME. - return std::wstring(); + auto path = GetExecutablePath(); + return xe::find_base_path(path); } std::wstring GetUserFolder() { - assert_always(); // IMPLEMENT ME. - return std::wstring(); + // get preferred data home + char* dataHome = std::getenv("XDG_DATA_HOME"); + + // if XDG_DATA_HOME not set, fallback to HOME directory + if (dataHome == NULL) { + dataHome = std::getenv("HOME"); + } else { + std::string home(dataHome); + return to_wstring(home); + } + + // if HOME not set, fall back to this + if (dataHome == NULL) { + struct passwd pw1; + struct passwd* pw; + char buf[4096]; // could potentionally lower this + getpwuid_r(getuid(), &pw1, buf, sizeof(buf), &pw); + assert(&pw1 == pw); // sanity check + dataHome = pw->pw_dir; + } + + std::string home(dataHome); + return to_wstring(home + "/.local/share"); } bool PathExists(const std::wstring& path) { diff --git a/src/xenia/base/string.cc b/src/xenia/base/string.cc index feff3a21b..54a8d7ebf 100644 --- a/src/xenia/base/string.cc +++ b/src/xenia/base/string.cc @@ -9,12 +9,27 @@ #include "xenia/base/string.h" -// TODO(benvanik): when GCC finally gets codecvt, use that. -#if XE_PLATFORM_LINUX +// codecvt existence check +#ifdef __clang__ +// using clang +#if (__clang_major__ < 4) // 3.3 has it but I think we need at least 4 anyway +// insufficient clang version #define NO_CODECVT 1 #else #include -#endif // XE_PLATFORM_LINUX +#endif +#elif defined(__GNUC__) || defined(__GNUG__) +// using gcc +#if (__GNUC__ < 5) +// insufficient clang version +#define NO_CODECVT 1 +#else +#include +#endif +// since the windows 10 sdk is required, this shouldn't be an issue +#elif defined(_MSC_VER) +#include +#endif #include #include