comparison src/core/filesystem.cc @ 176:121c2d5b321f

anime/db: finalize anime db cache
author Paper <mrpapersonic@gmail.com>
date Fri, 01 Dec 2023 13:12:26 -0500
parents 80d6b28eb29f
children 8548dc425697
comparison
equal deleted inserted replaced
175:9b10175be389 176:121c2d5b321f
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 return std::filesystem::path(osx::GetApplicationSupportDirectory()) / CONFIG_DIR;
50 #else // just assume POSIX 53 #else // just assume POSIX
51 std::filesystem::path path; 54 std::filesystem::path path;
52 const char* home = getenv("HOME"); 55 const char* home = getenv("HOME");
56
53 # ifdef __linux__ 57 # ifdef __linux__
54 if (!home) 58 if (!home)
55 home = getpwuid(getuid())->pw_dir; 59 home = getpwuid(getuid())->pw_dir;
56 # endif // __linux__ 60 # endif // __linux__
61
62 /* only do this if the home directory was really found */
57 if (home) 63 if (home)
58 return std::filesystem::path(home) / ".config" / CONFIG_DIR; 64 return std::filesystem::path(home) / ".config" / CONFIG_DIR;
59 else 65 else
60 return std::filesystem::path(); 66 return std::filesystem::path();
61 #endif // !WIN32 && !MACOSX 67 #endif // !WIN32 && !MACOSX