[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() { std::wstring GetUserFolder() {
wchar_t path[MAX_PATH]; std::wstring result;
if (!SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_MYDOCUMENTS, nullptr, PWSTR path;
SHGFP_TYPE_CURRENT, path))) { if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_DEFAULT,
return std::wstring(); nullptr, &path))) {
result.assign(path);
CoTaskMemFree(path);
} }
return std::wstring(path); return result;
} }
bool PathExists(const std::wstring& path) { bool PathExists(const std::wstring& path) {