forked from qt-creator/qt-creator
Utils: Introduce a non-mutating FileName::pathAppended
... and start using it. The plan is to replace all appendPath() uses. Change-Id: I555bcfa742b99b0951b98b0c0e707422c348fadb Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -166,10 +166,8 @@ bool FileUtils::copyRecursively(const FileName &srcFilePath, const FileName &tgt
|
||||
QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot
|
||||
| QDir::Hidden | QDir::System);
|
||||
foreach (const QString &fileName, fileNames) {
|
||||
FileName newSrcFilePath = srcFilePath;
|
||||
newSrcFilePath.appendPath(fileName);
|
||||
FileName newTgtFilePath = tgtFilePath;
|
||||
newTgtFilePath.appendPath(fileName);
|
||||
const FileName newSrcFilePath = srcFilePath.pathAppended(fileName);
|
||||
const FileName newTgtFilePath = tgtFilePath.pathAppended(fileName);
|
||||
if (!copyRecursively(newSrcFilePath, newTgtFilePath, error, copyHelper))
|
||||
return false;
|
||||
}
|
||||
@@ -855,6 +853,17 @@ FileName &FileName::appendPath(const QString &s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
FileName FileName::pathAppended(const QString &str) const
|
||||
{
|
||||
FileName fn = *this;
|
||||
if (str.isEmpty())
|
||||
return fn;
|
||||
if (!isEmpty() && !m_data.endsWith(QLatin1Char('/')))
|
||||
fn.m_data.append('/');
|
||||
fn.m_data.append(str);
|
||||
return fn;
|
||||
}
|
||||
|
||||
FileName FileName::stringAppended(const QString &str) const
|
||||
{
|
||||
FileName fn = *this;
|
||||
|
||||
Reference in New Issue
Block a user