summaryrefslogtreecommitdiff
path: root/src/lib/tools
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2013-08-28 10:03:20 +0200
committerJoerg Bornemann <joerg.bornemann@digia.com>2013-08-30 12:13:41 +0200
commitf1b6d6624b24e699f1339de18b7b384fe5a844ca (patch)
tree880fc8f0c903f8523d07a6e3e0ccb78cc8c71eb9 /src/lib/tools
parent019c8a2a2b8783f80cd268804c74ebd76aa564b8 (diff)
downloadqbs-f1b6d6624b24e699f1339de18b7b384fe5a844ca.tar.gz
Always try to create the target directory when copying files.
There is not much sense in limiting this to the case of the source file being a directory, as in the current implementation. Change-Id: Ic8e516cd182a551af8ee0fce2517649388edb234 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/lib/tools')
-rw-r--r--src/lib/tools/fileinfo.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/lib/tools/fileinfo.cpp b/src/lib/tools/fileinfo.cpp
index 537dc313e..ffdf3f598 100644
--- a/src/lib/tools/fileinfo.cpp
+++ b/src/lib/tools/fileinfo.cpp
@@ -421,6 +421,12 @@ bool copyFileRecursion(const QString &srcFilePath, const QString &tgtFilePath,
{
QFileInfo srcFileInfo(srcFilePath);
QFileInfo tgtFileInfo(tgtFilePath);
+ const QString targetDirPath = tgtFileInfo.absoluteDir().path();
+ if (!QDir::root().mkpath(targetDirPath)) {
+ *errorMessage = Tr::tr("The directory '%1' could not be created.")
+ .arg(QDir::toNativeSeparators(targetDirPath));
+ return false;
+ }
if (HostOsInfo::isAnyUnixHost() && preserveSymLinks && srcFileInfo.isSymLink()) {
// For now, disable symlink preserving copying on Windows.
// MS did a good job to prevent people from using symlinks - even if they are supported.
@@ -430,13 +436,6 @@ bool copyFileRecursion(const QString &srcFilePath, const QString &tgtFilePath,
return false;
}
} else if (srcFileInfo.isDir()) {
- QDir targetDir(tgtFilePath);
- targetDir.cdUp();
- if (!targetDir.mkpath(tgtFileInfo.fileName())) {
- *errorMessage = Tr::tr("The directory '%1' could not be created.")
- .arg(QDir::toNativeSeparators(tgtFilePath));
- return false;
- }
QDir sourceDir(srcFilePath);
QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot
| QDir::Hidden | QDir::System);