Mercurial > minori
diff src/filesystem.cpp @ 7:07a9095eaeed
Update
Refactored some code, moved some around
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Thu, 24 Aug 2023 23:11:38 -0400 |
parents | 51ae25154b70 |
children |
line wrap: on
line diff
--- a/src/filesystem.cpp Wed Aug 16 00:49:17 2023 -0400 +++ b/src/filesystem.cpp Thu Aug 24 23:11:38 2023 -0400 @@ -2,6 +2,10 @@ #include <shlobj.h> #elif defined(MACOSX) #include "sys/osx/filesystem.h" +#elif defined(__linux__) +#include <unistd.h> +#include <sys/types.h> +#include <pwd.h> #endif #include <filesystem> #include <limits.h> @@ -17,10 +21,15 @@ if (SHGetFolderPathAndSubDir(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, CONFIG_DIR, buf) == S_OK) cfg_path = std::filesystem::path(buf) / CONFIG_NAME; #elif defined(MACOSX) - /* hope and pray that std::filesystem can handle tildes... */ + /* pass all of our problems to */ cfg_path = std::filesystem::path(StringUtils::Utf8ToWstr(osx::GetApplicationSupportDirectory())) / CONFIG_DIR / CONFIG_NAME; #else // just assume POSIX - cfg_path = std::filesystem::path(getenv("HOME")) / ".config" / CONFIG_DIR / CONFIG_NAME; + if (getenv("HOME") != NULL) + cfg_path = std::filesystem::path(getenv("HOME")) / ".config" / CONFIG_DIR / CONFIG_NAME; +#ifdef __linux__ + else + cfg_path = std::filesystem::path(getpwuid(getuid())->pw_dir) / ".config" / CONFIG_DIR / CONFIG_NAME; +#endif // __linux__ #endif return cfg_path; }