diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-03-18 16:25:26 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-04-15 14:37:48 +0200 |
commit | 4b37abc0c9c1a0e1bdb182e725e31daaf610dc7a (patch) | |
tree | 95eb1af3193f9336a7914571fd5c7f98d4c3fa7c /src | |
parent | 23b14237f8513a74c54223f95c8abea43c972b83 (diff) |
Port qfilesystemengine_win.cpp to QRegularExpression
QRegExp is going away in Qt 6.
Change-Id: I282a444b9fdf1c834dcf90d7fd6743781b94643c
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qfilesystemengine_win.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 6ad123f3b6..75ad5d3cc5 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -53,6 +53,9 @@ #include "qdatetime.h" #include "qt_windows.h" #include "qvector.h" +#if QT_CONFIG(regularexpression) +#include "qregularexpression.h" +#endif #include <sys/types.h> #include <direct.h> @@ -329,15 +332,17 @@ static QString readSymLink(const QFileSystemEntry &link) free(rdb); CloseHandle(handle); -#if QT_CONFIG(fslibs) +#if QT_CONFIG(fslibs) && QT_CONFIG(regularexpression) initGlobalSid(); - QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive); - if (matchVolName.indexIn(result) == 0) { + QRegularExpression matchVolumeRe(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), QRegularExpression::CaseInsensitiveOption); + auto matchVolume = matchVolumeRe.match(result); + if (matchVolume.hasMatch()) { + Q_ASSERT(matchVolume.capturedStart() == 0); DWORD len; wchar_t buffer[MAX_PATH]; - const QString volumeName = QLatin1String("\\\\?\\") + result.leftRef(matchVolName.matchedLength()); + const QString volumeName = QLatin1String("\\\\?\\") + matchVolume.captured(); if (GetVolumePathNamesForVolumeName(reinterpret_cast<LPCWSTR>(volumeName.utf16()), buffer, MAX_PATH, &len) != 0) - result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer)); + result.replace(0, matchVolume.capturedLength(), QString::fromWCharArray(buffer)); } #endif // QT_CONFIG(fslibs) } |