[Base] Remove MAX_PATH limit from GetUserFolder

Replace SHGetFolderPath with SHGetKnownFolderPath to remove the limit
This commit is contained in:
Silent 2019-08-31 14:14:13 +02:00 committed by Justin Moore
parent 6f2c39d8d1
commit 96a9397349
1 changed files with 7 additions and 5 deletions

View File

@ -31,12 +31,14 @@ std::wstring GetExecutableFolder() {
}
std::wstring GetUserFolder() {
wchar_t path[MAX_PATH];
if (!SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_MYDOCUMENTS, nullptr,
SHGFP_TYPE_CURRENT, path))) {
return std::wstring();
std::wstring result;
PWSTR path;
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_DEFAULT,
nullptr, &path))) {
result.assign(path);
CoTaskMemFree(path);
}
return std::wstring(path);
return result;
}
bool PathExists(const std::wstring& path) {