qdir_temppath.patch raw
1 --- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
2 +++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
3 @@ -1390,7 +1390,15 @@
4 QString ret;
5 #ifndef Q_OS_WINRT
6 wchar_t tempPath[MAX_PATH];
7 - const DWORD len = GetTempPath(MAX_PATH, tempPath);
8 + using GetTempPathPrototype = DWORD (WINAPI *)(DWORD, LPWSTR);
9 + // We try to resolve GetTempPath2 and use that, otherwise fall back to GetTempPath:
10 + static GetTempPathPrototype getTempPathW = []() {
11 + const HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
12 + if (auto *func = QFunctionPointer(GetProcAddress(kernel32, "GetTempPath2W")))
13 + return GetTempPathPrototype(func);
14 + return GetTempPath;
15 + }();
16 + const DWORD len = getTempPathW(MAX_PATH, tempPath);
17 if (len) { // GetTempPath() can return short names, expand.
18 wchar_t longTempPath[MAX_PATH];
19 const DWORD longLen = GetLongPathName(tempPath, longTempPath, MAX_PATH);
20