From 7502169622439e539b9ca875bb35df0b82b1b428 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 20 Mar 2015 13:10:28 +0100 Subject: [PATCH] Variable manager: Provide file path variables with native separators Since we cannot know if the path should be represented with native separators or not, we have to leave the decision to the user, by providing separate variables for it. Change-Id: I4d06d0a29627f4e82f8b2c7acac06f442c5c5eb4 Task-number: QTCREATORBUG-11896 Reviewed-by: Daniel Teske --- src/libs/utils/macroexpander.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/libs/utils/macroexpander.cpp b/src/libs/utils/macroexpander.cpp index 4047929f101..2d188426342 100644 --- a/src/libs/utils/macroexpander.cpp +++ b/src/libs/utils/macroexpander.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include @@ -45,6 +46,8 @@ namespace Internal { const char kFilePathPostfix[] = ":FilePath"; const char kPathPostfix[] = ":Path"; +const char kNativeFilePathPostfix[] = ":NativeFilePath"; +const char kNativePathPostfix[] = ":NativePath"; const char kFileNamePostfix[] = ":FileName"; const char kFileBaseNamePostfix[] = ":FileBaseName"; @@ -370,6 +373,22 @@ void MacroExpander::registerFileVariables(const QByteArray &prefix, [base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).path(); }, visibleInChooser); + registerVariable(prefix + kNativeFilePathPostfix, + tr("%1: Full path including file name, with native path separator (backslash on Windows).").arg(heading), + [base]() -> QString { + QString tmp = base(); + return tmp.isEmpty() ? QString() : QDir::toNativeSeparators(QFileInfo(tmp).filePath()); + }, + visibleInChooser); + + registerVariable(prefix + kNativePathPostfix, + tr("%1: Full path excluding file name, with native path separator (backslash on Windows).").arg(heading), + [base]() -> QString { + QString tmp = base(); + return tmp.isEmpty() ? QString() : QDir::toNativeSeparators(QFileInfo(tmp).path()); + }, + visibleInChooser); + registerVariable(prefix + kFileNamePostfix, tr("%1: File name without path.").arg(heading), [base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : Utils::FileName::fromString(tmp).fileName(); },