comparison src/core/filesystem.cc @ 202:71832ffe425a

animia: re-add kvm fd source this is all being merged from my wildly out-of-date laptop. SORRY! in other news, I edited the CI file to install the wayland client as well, so the linux CI build might finally get wayland stuff.
author Paper <paper@paper.us.eu.org>
date Tue, 02 Jan 2024 06:05:06 -0500
parents 8548dc425697
children 53211cb1e7f5
comparison
equal deleted inserted replaced
201:8f6f8dd2eb23 202:71832ffe425a
37 37
38 std::filesystem::path GetDotPath() { 38 std::filesystem::path GetDotPath() {
39 #ifdef WIN32 39 #ifdef WIN32
40 std::filesystem::path path; 40 std::filesystem::path path;
41 wchar_t* buf; 41 wchar_t* buf;
42
42 if (SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_CREATE, NULL, &buf) == S_OK) 43 if (SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_CREATE, NULL, &buf) == S_OK)
43 path = buf; 44 path = buf;
44 else 45 else
45 return std::filesystem::path(); 46 return std::filesystem::path();
47
46 CoTaskMemFree(buf); 48 CoTaskMemFree(buf);
49
47 return path / CONFIG_DIR; 50 return path / CONFIG_DIR;
48 #elif defined(MACOSX) 51 #elif defined(MACOSX)
49 return std::filesystem::path(osx::GetApplicationSupportDirectory()) / CONFIG_DIR; 52 std::string appsupport;
53 if (!osx::GetApplicationSupportDirectory(appsupport))
54 return "";
55
56 return std::filesystem::path(appsupport) / CONFIG_DIR;
50 #else // just assume POSIX 57 #else // just assume POSIX
51 std::filesystem::path path; 58 std::filesystem::path path;
52 const char* home = getenv("HOME"); 59 const char* home = getenv("HOME");
60
53 # ifdef __linux__ 61 # ifdef __linux__
54 if (!home) 62 if (!home)
55 home = getpwuid(getuid())->pw_dir; 63 home = getpwuid(getuid())->pw_dir;
56 # endif // __linux__ 64 # endif // __linux__
65
66 /* only do this if the home directory was really found */
57 if (home) 67 if (home)
58 return std::filesystem::path(home) / ".config" / CONFIG_DIR; 68 return std::filesystem::path(home) / ".config" / CONFIG_DIR;
59 else 69 else
60 return std::filesystem::path(); 70 return std::filesystem::path();
61 #endif // !WIN32 && !MACOSX 71 #endif // !WIN32 && !MACOSX