mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 08:55:43 +08:00
Improved string concat to avoid "//" in paths
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <QStringBuilder>
|
||||||
|
|
||||||
using namespace BlackConfig;
|
using namespace BlackConfig;
|
||||||
using namespace BlackMisc::Math;
|
using namespace BlackMisc::Math;
|
||||||
@@ -115,7 +116,13 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
if (path1.isEmpty()) { return QDir::cleanPath(path2); }
|
if (path1.isEmpty()) { return QDir::cleanPath(path2); }
|
||||||
if (path2.isEmpty()) { return QDir::cleanPath(path1); }
|
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)
|
QString CFileUtils::appendFilePathsAndFixUnc(const QString &path1, const QString &path2)
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ namespace BlackMisc
|
|||||||
|
|
||||||
QString CUrl::appendPath(const QString &pathToAppend)
|
QString CUrl::appendPath(const QString &pathToAppend)
|
||||||
{
|
{
|
||||||
QString p(getPath());
|
if (pathToAppend.isEmpty()) { return m_path; }
|
||||||
p = p.append("/").append(pathToAppend.trimmed()).replace("//", "/");
|
const QString p = CFileUtils::appendFilePaths(this->getPath(), pathToAppend);
|
||||||
this->setPath(p);
|
this->setPath(p);
|
||||||
return m_path;
|
return m_path;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user