summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/fileutils.cpp
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2013-01-21 12:52:13 +0100
committerTim Jenssen <tim.jenssen@digia.com>2013-01-23 13:58:27 +0100
commit01cbce9e057a1ca951d99558feaea5b6f7620541 (patch)
treed0fd5fc5bc0b13f923d7a0099dd6e85c04477102 /src/libs/installer/fileutils.cpp
parent590457501a6edbc732a3a6243305b61bf5dbaf08 (diff)
Fix some warnings in our code after Idcfec77.
Change-Id: Ied8ffad416ae058a45fa2d46f8ff304ff5b4a392 Reviewed-by: Niels Weber <niels.weber@digia.com> Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Diffstat (limited to 'src/libs/installer/fileutils.cpp')
-rw-r--r--src/libs/installer/fileutils.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp
index febf239f1..b95ca4a1c 100644
--- a/src/libs/installer/fileutils.cpp
+++ b/src/libs/installer/fileutils.cpp
@@ -254,6 +254,18 @@ void QInstaller::removeFiles(const QString &path, bool ignoreErrors)
}
}
+static QString errnoToQString(int error)
+{
+#ifdef Q_OS_WIN
+ char msg[128];
+ if (strerror_s(msg, sizeof msg, error) != 0)
+ return QString::fromLocal8Bit(msg);
+ return QString();
+#else
+ return QString::fromLocal8Bit(strerror(error));
+#endif
+}
+
void QInstaller::removeDirectory(const QString &path, bool ignoreErrors)
{
if (path.isEmpty()) // QDir("") points to the working directory! We never want to remove that one.
@@ -275,7 +287,7 @@ void QInstaller::removeDirectory(const QString &path, bool ignoreErrors)
errno = 0;
if (d.exists(path) && !d.rmdir(dir)) {
QString errorMessage = QObject::tr("Could not remove folder %1: %2").arg(dir,
- QLatin1String(strerror(errno)));
+ errnoToQString(errno));
if (ignoreErrors)
qWarning() << errorMessage;
else
@@ -396,19 +408,15 @@ void QInstaller::moveDirectoryContents(const QString &sourceDir, const QString &
void QInstaller::mkdir(const QString &path)
{
errno = 0;
- if (!QDir().mkdir(QFileInfo(path).absoluteFilePath())) {
- throw Error(QObject::tr("Could not create folder %1: %2").arg(path,
- QString::fromLocal8Bit(strerror(errno))));
- }
+ if (!QDir().mkdir(QFileInfo(path).absoluteFilePath()))
+ throw Error(QObject::tr("Could not create folder %1: %2").arg(path, errnoToQString(errno)));
}
void QInstaller::mkpath(const QString &path)
{
errno = 0;
- if (!QDir().mkpath(QFileInfo(path).absoluteFilePath())) {
- throw Error(QObject::tr("Could not create folder %1: %2").arg(path,
- QString::fromLocal8Bit(strerror(errno))));
- }
+ if (!QDir().mkpath(QFileInfo(path).absoluteFilePath()))
+ throw Error(QObject::tr("Could not create folder %1: %2").arg(path, errnoToQString(errno)));
}
QString QInstaller::generateTemporaryFileName(const QString &templ)