| 109 | } |
| 110 | |
| 111 | const std::string get_user_dir(const UserDir userdir) { |
| 112 | int cdret = 0; |
| 113 | std::string configPath; |
| 114 | PWSTR envVar = nullptr; |
| 115 | if (userdir == UserDir::Config) |
| 116 | SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &envVar); |
| 117 | else if (userdir == UserDir::Data) |
| 118 | SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &envVar); |
| 119 | |
| 120 | if (envVar) { |
| 121 | configPath = utf16_to_utf8(envVar); |
| 122 | configPath += "\\" OBV_NAME "\\"; |
| 123 | auto configPathu16 = utf8_to_utf16(configPath); |
| 124 | cdret = CreateDirectoryW(configPathu16.c_str(), NULL); // Doesn't work recursively but it's not an issue here |
| 125 | } |
| 126 | CoTaskMemFree(envVar); |
| 127 | |
| 128 | if (configPath.empty() || (cdret == 0 && GetLastError() != ERROR_ALREADY_EXISTS)) configPath = ".\\"; // Fallback to current dir |
| 129 | return configPath; |
| 130 | } |
| 131 | |
| 132 | char *strcasestr(const char *str, const char *pattern) { |
| 133 | size_t i; |
nothing calls this directly
no test coverage detected