diff options
author | hjk <hjk@qt.io> | 2018-04-23 12:46:37 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2018-04-24 05:59:26 +0000 |
commit | 58f0a7a3ddb134be1c50e72c200283d43a5c32e6 (patch) | |
tree | 52827ab0d2c44739dfb5ca1477b1064af7d99834 /src/libs/utils | |
parent | d269e9a4925507d008445512becf02ea06be1054 (diff) |
Utils: Introduce a OsSpecificAspect::pathWithNativeSeparators(QString)
... and use it in the ExecutableAspect implementation.
Change-Id: I0d242d9969323e495e16997e1ca46cfc10e8eb4b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/libs/utils')
-rw-r--r-- | src/libs/utils/osspecificaspects.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libs/utils/osspecificaspects.h b/src/libs/utils/osspecificaspects.h index 15609794c9..e588c54fc0 100644 --- a/src/libs/utils/osspecificaspects.h +++ b/src/libs/utils/osspecificaspects.h @@ -29,6 +29,8 @@ #include <QString> +#include <algorithm> + #define QTC_WIN_EXE_SUFFIX ".exe" namespace Utils { @@ -60,6 +62,18 @@ public: return m_osType == OsTypeMac ? Qt::MetaModifier : Qt::ControlModifier; } + QString pathWithNativeSeparators(const QString &pathName) const { + if (m_osType == OsTypeWindows) { + const int pos = pathName.indexOf('/'); + if (pos >= 0) { + QString n = pathName; + std::replace(std::begin(n) + pos, std::end(n), '/', '\\'); + return n; + } + } + return pathName; + } + private: const OsType m_osType; }; |