From 96805a53d08a2f86b19aa77255a1e6467513def2 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 20 Apr 2010 16:45:37 +0200 Subject: fix nativeFilePath character width issue the variable is a byte array, but it holds wchar_t's. Reviewed-by: joerg --- src/corelib/io/qfsfileengine_win.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index eeca07e..ec49f1a 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -542,11 +542,13 @@ qint64 QFSFileEnginePrivate::nativeSize() const if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { QByteArray path = nativeFilePath; // path for the FindFirstFile should not end with a trailing slash - while (path.endsWith('\\')) - path.chop(1); + while (!path.isEmpty() && reinterpret_cast( + path.constData() + path.length())[-1] == '\\') + path.chop(2); // FindFirstFile can not handle drives - if (!path.endsWith(':')) { + if (!path.isEmpty() && reinterpret_cast( + path.constData() + path.length())[-1] != ':') { WIN32_FIND_DATA findData; HANDLE hFind = ::FindFirstFile((const wchar_t*)path.constData(), &findData); -- cgit v0.12