Skip to content

Utility: update Path::{home,configuration}Directory() on Windows. #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

williamjcm
Copy link
Contributor

Instead of the old SHGetFolderPathW() API, they now use the SHGetKnownFolderPath() API, which was added in Windows Vista.

As a side effect, if OneDrive is installed, homeDirectory() should now return the proper Documents directory, instead of the OneDrive equivalent. Though I couldn't test that, because I made sure to remove it from my machine as soon as possible.

Instead of the old SHGetFolderPathW() API, they now use the
SHGetKnownFolderPath() API, which was added in Windows Vista. As a side
effect, if OneDrive is installed, homeDirectory() will now return the
proper Documents directory, instead of the OneDrive equivalent.
@williamjcm williamjcm force-pushed the path-windows-use-knownfolder-api branch from f21f4e4 to 32fa8b5 Compare June 11, 2022 16:51
@mosra mosra added this to the 2022.0a milestone Jun 11, 2022
@mosra
Copy link
Owner

mosra commented Jun 11, 2022

Ignore the Apple CI failures, I cancelled them because they just wait forever (5d6fed8 will fix that).

Let's see what AppVeyor says, then I'll merge.

@mosra
Copy link
Owner

mosra commented Jun 12, 2022

To fix MinGW, this could help I think.

diff --git a/src/Corrade/Utility/Path.cpp b/src/Corrade/Utility/Path.cpp
index 5a365189..08646468 100644
--- a/src/Corrade/Utility/Path.cpp
+++ b/src/Corrade/Utility/Path.cpp
@@ -74,6 +74,10 @@
 /** @todo remove the superfluous includes when mingw is fixed (otherwise causes undefined EXTERN_C error) */
 #ifdef CORRADE_TARGET_WINDOWS
 #ifdef __MINGW32__
+/* For SHGetKnownFolderPath() on MinGW: https://stackoverflow.com/a/59033437 */
+#ifndef NTDDI_VERSION
+#define NTDDI_VERSION 0x06000000
+#endif
 #include <wtypes.h>
 #include <windef.h>
 #include <wincrypt.h>

And if you rebase on master, the Mac CI stops being cursed.

@mosra
Copy link
Owner

mosra commented Jun 18, 2022

Merged as 20c1ba3, with the MinGW patch applied as 612c49a. Thank you for the fix! 👍

@mosra mosra closed this Jun 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants