@@ -36,12 +36,14 @@ namespace Files
3636 {
3737 std::filesystem::path userPath = std::filesystem::current_path ();
3838
39- WCHAR path[MAX_PATH + 1 ] = {};
39+ PWSTR cString;
40+ HRESULT result = SHGetKnownFolderPath (FOLDERID_Documents, 0 , nullptr , &cString);
41+ if (SUCCEEDED (result))
42+ userPath = std::filesystem::path (cString);
43+ else
44+ Log (Debug::Error) << " Error " << result << " when getting Documents path" ;
4045
41- if (SUCCEEDED (SHGetFolderPathW (nullptr , CSIDL_PERSONAL | CSIDL_FLAG_CREATE, nullptr , 0 , path)))
42- {
43- userPath = std::filesystem::path (path);
44- }
46+ CoTaskMemFree (cString);
4547
4648 return userPath / " My Games" / mName ;
4749 }
@@ -54,14 +56,19 @@ namespace Files
5456
5557 std::filesystem::path WindowsPath::getGlobalConfigPath () const
5658 {
59+ // The concept of a global config path is absurd on Windows.
60+ // Always use local config instead.
61+ // The virtual base class requires that we provide this, though.
5762 std::filesystem::path globalPath = std::filesystem::current_path ();
5863
59- WCHAR path[MAX_PATH + 1 ] = {};
64+ PWSTR cString;
65+ HRESULT result = SHGetKnownFolderPath (FOLDERID_ProgramFiles, 0 , nullptr , &cString);
66+ if (SUCCEEDED (result))
67+ globalPath = std::filesystem::path (cString);
68+ else
69+ Log (Debug::Error) << " Error " << result << " when getting Program Files path" ;
6070
61- if (SUCCEEDED (SHGetFolderPathW (nullptr , CSIDL_PROGRAM_FILES | CSIDL_FLAG_CREATE, nullptr , 0 , path)))
62- {
63- globalPath = std::filesystem::path (path);
64- }
71+ CoTaskMemFree (cString);
6572
6673 return globalPath / mName ;
6774 }
0 commit comments