diff options
| author | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-03-19 16:27:36 +0100 |
|---|---|---|
| committer | Christian Kandeler <christian.kandeler@digia.com> | 2013-03-20 10:26:40 +0100 |
| commit | 27786bfef9ce56738ab337e2fafcfe15e2f97c9f (patch) | |
| tree | 5b6754ab62a9c3e33d184ebb1ca29cc3137f55f5 | |
| parent | 6e42b331601a235be32364ee759616240b6f4d2f (diff) | |
| download | qbs-27786bfef9ce56738ab337e2fafcfe15e2f97c9f.tar.gz | |
beautify ccp function in tst_blackbox.cpp
Use meaningful variable names, fix whitespace issues and reuse already
computed values.
Change-Id: Ic062a201b15a152feb5f9d5587fff809699e8f32
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
| -rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index a8207a495..ddbc178ed 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -95,22 +95,23 @@ int TestBlackbox::runQbs(QStringList arguments, bool expectFailure, bool useProf Recursive copy from directory to another. Note that this updates the file stamps on Linux but not on Windows. */ -static void ccp(const QString &from, const QString &to) -{ - QDirIterator it(from, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden); - while (it.hasNext()) { - it.next(); - QDir().mkpath(to + "/" + it.fileName()); - ccp(from + "/" + it.fileName(), to + "/" + it.fileName()); +static void ccp(const QString &sourceDirPath, const QString &targetDirPath) +{ + QDir currentDir; + QDirIterator dit(sourceDirPath, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden); + while (dit.hasNext()) { + dit.next(); + const QString targetPath = targetDirPath + QLatin1Char('/') + dit.fileName(); + currentDir.mkpath(targetPath); + ccp(dit.filePath(), targetPath); } - QDirIterator it2(from, QDir::Files| QDir::NoDotAndDotDot | QDir::Hidden); - while (it2.hasNext()) { - it2.next(); - const QString dstFilePath = to + "/" + it2.fileName(); - if (QFile::exists(dstFilePath)) - QFile::remove(dstFilePath); - QFile(from + "/" + it2.fileName()).copy(dstFilePath); + QDirIterator fit(sourceDirPath, QDir::Files | QDir::Hidden); + while (fit.hasNext()) { + fit.next(); + const QString targetPath = targetDirPath + QLatin1Char('/') + fit.fileName(); + QFile::remove(targetPath); // allowed to fail + QVERIFY(QFile::copy(fit.filePath(), targetPath)); } } |
