diff --git a/src/libs/utils/winutils.cpp b/src/libs/utils/winutils.cpp index f19bdfefbe4..b731d273bb0 100644 --- a/src/libs/utils/winutils.cpp +++ b/src/libs/utils/winutils.cpp @@ -173,6 +173,9 @@ QTCREATOR_UTILS_EXPORT QString normalizePathName(const QString &name) canonicalName = getLongPathName(canonicalName); if (canonicalName.isEmpty()) return name; + // Upper case drive letter + if (canonicalName.size() > 2 && canonicalName.at(1) == QLatin1Char(':')) + canonicalName[0] = canonicalName.at(0).toUpper(); return canonicalName; } diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 81b448db911..f44cff77d01 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -2477,7 +2477,7 @@ CdbEngine::NormalizedSourceFileName CdbEngine::sourceMapNormalizeFileNameFromDeb DebuggerToSource); // Up/lower case normalization according to Windows. #ifdef Q_OS_WIN - QString normalized = winNormalizeFileName(fileName); + QString normalized = Utils::normalizePathName(fileName); #else QString normalized = fileName; #endif diff --git a/src/plugins/debugger/shared/dbgwinutils.cpp b/src/plugins/debugger/shared/dbgwinutils.cpp index b18a700b89b..cd70411e5ba 100644 --- a/src/plugins/debugger/shared/dbgwinutils.cpp +++ b/src/plugins/debugger/shared/dbgwinutils.cpp @@ -200,53 +200,6 @@ static bool mapDeviceToDriveLetter(QString *s) return false; } -// Determine normalized case of a Windows file name (camelcase.cpp -> CamelCase.cpp) -// Restriction: File needs to exists and be non-empty and will be to be opened/mapped. -// This is the MSDN-recommended way of doing that. - -QString winNormalizeFileName(const QString &f) -{ - HANDLE hFile = CreateFile((const wchar_t*)f.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if(hFile == INVALID_HANDLE_VALUE) - return f; - // Get the file size. We need a non-empty file to map it. - DWORD dwFileSizeHi = 0; - DWORD dwFileSizeLo = GetFileSize(hFile, &dwFileSizeHi); - if (dwFileSizeLo == 0 && dwFileSizeHi == 0) { - CloseHandle(hFile); - return f; - } - // Create a file mapping object. - HANDLE hFileMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 1, NULL); - if (!hFileMap) { - CloseHandle(hFile); - return f; - } - - // Create a file mapping to get the file name. - void* pMem = MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 1); - if (!pMem) { - CloseHandle(hFileMap); - CloseHandle(hFile); - return f; - } - - QString rc; - WCHAR pszFilename[MAX_PATH]; - pszFilename[0] = 0; - // Get a file name of the form "/Device/HarddiskVolume1/file.cpp" - if (GetMappedFileName (GetCurrentProcess(), pMem, pszFilename, MAX_PATH)) { - rc = QString::fromWCharArray(pszFilename); - if (!mapDeviceToDriveLetter(&rc)) - rc.clear(); - } - - UnmapViewOfFile(pMem); - CloseHandle(hFileMap); - CloseHandle(hFile); - return rc.isEmpty() ? f : rc; -} - bool isWinProcessBeingDebugged(unsigned long pid) { HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); diff --git a/src/plugins/debugger/shared/dbgwinutils.h b/src/plugins/debugger/shared/dbgwinutils.h index 02a6572829b..bc43f5cca21 100644 --- a/src/plugins/debugger/shared/dbgwinutils.h +++ b/src/plugins/debugger/shared/dbgwinutils.h @@ -53,14 +53,6 @@ bool winDebugBreakProcess(unsigned long pid, QString *errorMessage); unsigned long winGetCurrentProcessId(); -/* Helper for (case-)normalizing file names: - * Determine normalized case of a Windows file name (camelcase.cpp -> CamelCase.cpp) - * as the debugger reports lower case file names. - * Restriction: File needs to exist and be non-empty and will be to be opened/mapped. - * The result should be cached as the function can be extensive. */ - -QString winNormalizeFileName(const QString &f); - bool isWinProcessBeingDebugged(unsigned long pid); // Special exception codes.