mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 23:45:35 +08:00
Improved string concat to avoid "//" in paths
This commit is contained in:
committed by
Mat Sutcliffe
parent
fa8eed1611
commit
458daa4532
@@ -26,6 +26,7 @@
|
||||
#include <QtGlobal>
|
||||
#include <QMap>
|
||||
#include <algorithm>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackConfig;
|
||||
using namespace BlackMisc::Math;
|
||||
@@ -115,7 +116,13 @@ namespace BlackMisc
|
||||
{
|
||||
if (path1.isEmpty()) { return QDir::cleanPath(path2); }
|
||||
if (path2.isEmpty()) { return QDir::cleanPath(path1); }
|
||||
return QDir::cleanPath(path1 + QChar('/') + path2);
|
||||
if (path1.endsWith('/'))
|
||||
{
|
||||
// avoid double /
|
||||
if (path2.startsWith('/')) { return QDir::cleanPath(path1 % path2.mid(1)); }
|
||||
return QDir::cleanPath(path1 % path2);
|
||||
}
|
||||
return QDir::cleanPath(path1 % QChar('/') % path2);
|
||||
}
|
||||
|
||||
QString CFileUtils::appendFilePathsAndFixUnc(const QString &path1, const QString &path2)
|
||||
|
||||
@@ -53,8 +53,8 @@ namespace BlackMisc
|
||||
|
||||
QString CUrl::appendPath(const QString &pathToAppend)
|
||||
{
|
||||
QString p(getPath());
|
||||
p = p.append("/").append(pathToAppend.trimmed()).replace("//", "/");
|
||||
if (pathToAppend.isEmpty()) { return m_path; }
|
||||
const QString p = CFileUtils::appendFilePaths(this->getPath(), pathToAppend);
|
||||
this->setPath(p);
|
||||
return m_path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user