From 063c459054e228c27676b0b41478697c0db9f66e Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Sun, 4 Dec 2016 16:33:27 -0800 Subject: Make Win32 API usage long-path aware Most Win32 API functions are limited to working with paths which are up to MAX_PATH (260) characters long by default. Windows 10 version 1607 allows this limit to be exceeded by setting a LongPathsEnabled registry key and manifesting the application with the longPathAware=true setting. We cannot rely on this being the case since we support older Windows versions and the registry key is set to off by default. Fortunately, most Win32 API functions allow prepending the \\?\ prefix which raises the path length limit to UNICODE_STRING_MAX_CHARS (32767) characters. This works on all Windows versions. For the FileInfo class in particular, this resolves potential false negatives for file existence, inability to retrieve modification times, and misidentification of directories as files. Task-number: QBS-1068 Change-Id: Ia4a37fa75ede803e3e2ecb63ae1ab12d2dae33bd Reviewed-by: Oswald Buddenhagen Reviewed-by: Christian Kandeler --- src/lib/corelib/tools/vsenvironmentdetector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/corelib/tools/vsenvironmentdetector.cpp') diff --git a/src/lib/corelib/tools/vsenvironmentdetector.cpp b/src/lib/corelib/tools/vsenvironmentdetector.cpp index 291c150c9..4d359f85c 100644 --- a/src/lib/corelib/tools/vsenvironmentdetector.cpp +++ b/src/lib/corelib/tools/vsenvironmentdetector.cpp @@ -59,7 +59,7 @@ namespace Internal { static QString windowsSystem32Path() { #ifdef Q_OS_WIN - wchar_t str[MAX_PATH]; + wchar_t str[UNICODE_STRING_MAX_CHARS]; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_SYSTEM, NULL, 0, str))) return QString::fromUtf16(reinterpret_cast(str)); #endif -- cgit v1.2.3