From 67c23bb5e2f4170762ba0488c500f7a39c244851 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Thu, 9 Dec 2021 15:13:39 +0300 Subject: [PATCH] UI: FileUtil: Improve pathToKernelPath() --- src/ui/util/fileutil.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ui/util/fileutil.cpp b/src/ui/util/fileutil.cpp index 64559dc2..fa9be9b9 100644 --- a/src/ui/util/fileutil.cpp +++ b/src/ui/util/fileutil.cpp @@ -73,22 +73,24 @@ QString kernelPathToPath(const QString &kernelPath) QString pathToKernelPath(const QString &path, bool lower) { QString kernelPath = path; + if (path.size() > 1) { - const auto char1 = path.at(0); + const QChar char1 = path.at(0); if (char1.isLetter()) { if (path.at(1) == ':') { const QString drive = path.left(2); - kernelPath = driveToKernelName(drive) - + path.mid(2).replace(QLatin1Char('/'), QLatin1Char('\\')); - } else { - if (isSystemApp(path)) - return systemApp(); + kernelPath = driveToKernelName(drive) + path.mid(2); + } else if (isSystemApp(path)) { + return systemApp(); } } else if ((char1 == '?' || char1 == '*') && path.at(1) == ':') { // Replace "?:\\" with "\\Device\\*\\" kernelPath = "\\Device\\*" + path.mid(2); } } + + kernelPath = kernelPath.replace(QLatin1Char('/'), QLatin1Char('\\')); + return lower ? kernelPath.toLower() : kernelPath; }