summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libs/installer/fileutils.cpp34
-rw-r--r--src/libs/installer/fileutils.h3
2 files changed, 37 insertions, 0 deletions
diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp
index 77a54ed4d..9fb782fec 100644
--- a/src/libs/installer/fileutils.cpp
+++ b/src/libs/installer/fileutils.cpp
@@ -53,6 +53,12 @@
#include <errno.h>
+#ifdef Q_OS_UNIX
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
using namespace QInstaller;
@@ -469,6 +475,7 @@ QString QInstaller::createTemporaryDirectory(const QString &templ)
# endif
#include <windows.h>
+
QString QInstaller::getShortPathName(const QString &name)
{
if (name.isEmpty())
@@ -607,4 +614,31 @@ void QInstaller::setApplicationIcon(const QString &application, const QString &i
EndUpdateResourceW(updateRes, false);
}
+static quint64 symlinkSizeWin(const QString &path)
+{
+ WIN32_FILE_ATTRIBUTE_DATA fileAttributeData;
+ if (GetFileAttributesEx((wchar_t*)(path.utf16()), GetFileExInfoStandard, &fileAttributeData) == FALSE)
+ return quint64(0);
+
+ LARGE_INTEGER size;
+ size.LowPart = fileAttributeData.nFileSizeLow;
+ size.HighPart = fileAttributeData.nFileSizeHigh;
+ return quint64(size.QuadPart);
+}
+
#endif
+
+quint64 QInstaller::fileSize(const QFileInfo &info)
+{
+ if (!info.isSymLink())
+ return info.size();
+
+#ifndef Q_OS_WIN
+ struct stat buffer;
+ if (lstat(qPrintable(info.absoluteFilePath()), &buffer) != 0)
+ return quint64(0);
+ return quint64(buffer.st_size);
+#else
+ return symlinkSizeWin(info.absoluteFilePath());
+#endif
+}
diff --git a/src/libs/installer/fileutils.h b/src/libs/installer/fileutils.h
index 0450717cb..9bbcec72a 100644
--- a/src/libs/installer/fileutils.h
+++ b/src/libs/installer/fileutils.h
@@ -49,6 +49,7 @@
QT_BEGIN_NAMESPACE
class QByteArray;
+class QFileInfo;
class QIODevice;
class QUrl;
QT_END_NAMESPACE
@@ -120,6 +121,8 @@ private:
void INSTALLER_EXPORT mkdir(const QString &path);
void INSTALLER_EXPORT mkpath(const QString &path);
+ quint64 INSTALLER_EXPORT fileSize(const QFileInfo &info);
+
#ifdef Q_OS_WIN
QString INSTALLER_EXPORT getLongPathName(const QString &name);
QString INSTALLER_EXPORT getShortPathName(const QString &name);