From 6f2e71aacf9cf53a0b9db29b6a2eee4f1abd4767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Vogtl=C3=A4nder?= Date: Thu, 15 Aug 2019 12:04:05 +0200 Subject: [PATCH] Use unicode version of GetFileAttributesEx The ANSI version is restricted to MAX_PATH of 260 characters. The unicode version can handle path lengths up to 32,767 wide characters. GetFileAttributesExW requires absolute file names in UNC format (path is prefixed with "\\?\") --- src/jomlib/fastfileinfo.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/jomlib/fastfileinfo.cpp b/src/jomlib/fastfileinfo.cpp index a71241c..3532c87 100644 --- a/src/jomlib/fastfileinfo.cpp +++ b/src/jomlib/fastfileinfo.cpp @@ -63,8 +63,10 @@ FastFileInfo::FastFileInfo(const QString &fileName) if (z(m_attributes)->dwFileAttributes != INVALID_FILE_ATTRIBUTES) return; - if (!GetFileAttributesEx(reinterpret_cast(fileName.utf16()), - GetFileExInfoStandard, &m_attributes)) + QString uncFileName = QString::fromStdString("\\\\?\\") + + QDir::toNativeSeparators(QFileInfo(fileName).absoluteFilePath()); + if (!GetFileAttributesExW(reinterpret_cast(uncFileName.utf16()), + GetFileExInfoStandard, &m_attributes)) { z(m_attributes)->dwFileAttributes = INVALID_FILE_ATTRIBUTES; return; -- 2.19.2.windows.1