MCPcopy Create free account
hub / github.com/OpenBoardView/OpenBoardView / get_user_dir

Function get_user_dir

src/openboardview/win32.cpp:111–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111const 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
132char *strcasestr(const char *str, const char *pattern) {
133 size_t i;

Callers

nothing calls this directly

Calls 2

utf16_to_utf8Function · 0.85
utf8_to_utf16Function · 0.85

Tested by

no test coverage detected