summaryrefslogtreecommitdiffstats
path: root/src/libs/installer
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/installer')
-rw-r--r--src/libs/installer/adminauthorization_win.cpp8
-rw-r--r--src/libs/installer/binaryformat.cpp2
-rw-r--r--src/libs/installer/createlocalrepositoryoperation.cpp2
-rw-r--r--src/libs/installer/createshortcutoperation.cpp7
-rw-r--r--src/libs/installer/fileutils.cpp2
-rw-r--r--src/libs/installer/installer.pro4
-rw-r--r--src/libs/installer/lib7z_facade.cpp2
-rw-r--r--src/libs/installer/link.cpp52
8 files changed, 50 insertions, 29 deletions
diff --git a/src/libs/installer/adminauthorization_win.cpp b/src/libs/installer/adminauthorization_win.cpp
index 731fe044f..8d1f8352e 100644
--- a/src/libs/installer/adminauthorization_win.cpp
+++ b/src/libs/installer/adminauthorization_win.cpp
@@ -45,6 +45,12 @@
#include <QDebug>
#include <QDir>
+#ifdef Q_CC_MINGW
+# ifndef _WIN32_WINNT
+# define _WIN32_WINNT 0x0501
+# endif
+#endif
+
#include <windows.h>
struct DeCoInitializer
@@ -74,7 +80,7 @@ bool AdminAuthorization::authorize()
bool AdminAuthorization::hasAdminRights()
{
- SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY;
+ SID_IDENTIFIER_AUTHORITY authority = { SECURITY_NT_AUTHORITY };
PSID adminGroup;
// Initialize SID.
if (!AllocateAndInitializeSid(&authority,
diff --git a/src/libs/installer/binaryformat.cpp b/src/libs/installer/binaryformat.cpp
index 102a7bd87..50e4e24f3 100644
--- a/src/libs/installer/binaryformat.cpp
+++ b/src/libs/installer/binaryformat.cpp
@@ -311,7 +311,7 @@ bool Archive::copy(const QString &name)
errno = 0;
const QString absoluteFilePath = fileInfo.absoluteFilePath();
if (!fileInfo.exists() && !QDir().mkpath(absoluteFilePath)) {
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && !defined(Q_CC_MINGW)
char msg[128];
if (strerror_s(msg, sizeof msg, errno) != 0)
setErrorString(tr("Could not create %1: %2").arg(name, QString::fromLocal8Bit(msg)));
diff --git a/src/libs/installer/createlocalrepositoryoperation.cpp b/src/libs/installer/createlocalrepositoryoperation.cpp
index b401efb5d..758064488 100644
--- a/src/libs/installer/createlocalrepositoryoperation.cpp
+++ b/src/libs/installer/createlocalrepositoryoperation.cpp
@@ -371,7 +371,7 @@ bool CreateLocalRepositoryOperation::undoOperation()
errno = 0;
const bool result = QDir::root().rmdir(createdDir.path());
if (!result) {
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && !defined(Q_CC_MINGW)
char msg[128];
if (strerror_s(msg, sizeof msg, errno) != 0) {
setError(UserDefinedError, tr("Cannot remove directory %1: %2").arg(createdDir.path(),
diff --git a/src/libs/installer/createshortcutoperation.cpp b/src/libs/installer/createshortcutoperation.cpp
index 5142e65de..20be6bfa9 100644
--- a/src/libs/installer/createshortcutoperation.cpp
+++ b/src/libs/installer/createshortcutoperation.cpp
@@ -52,6 +52,11 @@
using namespace QInstaller;
#ifdef Q_OS_WIN
+#ifdef Q_CC_MINGW
+# ifndef _WIN32_WINNT
+# define _WIN32_WINNT 0x0501
+# endif
+#endif
#include <windows.h>
#include <shlobj.h>
@@ -192,7 +197,7 @@ bool CreateShortcutOperation::performOperation()
if (!created) {
setError(UserDefinedError);
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && !defined(Q_CC_MINGW)
char msg[128];
if (strerror_s(msg, sizeof msg, errno) != 0) {
setErrorString(tr("Could not create folder %1: %2.").arg(QDir::toNativeSeparators(linkPath),
diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp
index b95ca4a1c..9c8e9e50b 100644
--- a/src/libs/installer/fileutils.cpp
+++ b/src/libs/installer/fileutils.cpp
@@ -256,7 +256,7 @@ void QInstaller::removeFiles(const QString &path, bool ignoreErrors)
static QString errnoToQString(int error)
{
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && !defined(Q_CC_MINGW)
char msg[128];
if (strerror_s(msg, sizeof msg, error) != 0)
return QString::fromLocal8Bit(msg);
diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro
index 1f19e3e0d..322c3551c 100644
--- a/src/libs/installer/installer.pro
+++ b/src/libs/installer/installer.pro
@@ -170,7 +170,11 @@ unix:!macx:SOURCES += adminauthorization_x11.cpp
LIBS += -l7z
win32 {
SOURCES += adminauthorization_win.cpp
+
LIBS += -loleaut32 -luser32 # 7zip
LIBS += -ladvapi32 -lpsapi # kdtools
LIBS += -lole32 -lshell32 # createshortcutoperation
+
+ win32-g++*:LIBS += -lmpr -luuid
+ win32-g++*:QMAKE_CXXFLAGS += -Wno-missing-field-initializers
}
diff --git a/src/libs/installer/lib7z_facade.cpp b/src/libs/installer/lib7z_facade.cpp
index e987c7571..0c02890e2 100644
--- a/src/libs/installer/lib7z_facade.cpp
+++ b/src/libs/installer/lib7z_facade.cpp
@@ -185,7 +185,7 @@ static bool IsDST(const QDateTime& datetime = QDateTime())
{
const time_t seconds = static_cast< time_t >(datetime.isValid() ? datetime.toTime_t()
: QDateTime::currentDateTime().toTime_t());
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && !defined(Q_CC_MINGW)
struct tm t;
localtime_s(&t, &seconds);
#else
diff --git a/src/libs/installer/link.cpp b/src/libs/installer/link.cpp
index 19b50aa49..28f8190d5 100644
--- a/src/libs/installer/link.cpp
+++ b/src/libs/installer/link.cpp
@@ -50,10 +50,19 @@
#endif
#ifdef Q_OS_WIN
+#ifdef Q_CC_MINGW
+# ifndef _WIN32_WINNT
+# define _WIN32_WINNT 0x0501
+# endif
+#else
+# include <strsafe.h>
+#endif
+
#include <windows.h>
-#include <strsafe.h>
+#include <winioctl.h>
+
+#if !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
-// REPARSE_DATA_BUFFER structure from msdn help: http://msdn.microsoft.com/en-us/library/ff552012.aspx
typedef struct _REPARSE_DATA_BUFFER {
ULONG ReparseTag;
USHORT ReparseDataLength;
@@ -79,8 +88,9 @@ typedef struct _REPARSE_DATA_BUFFER {
} GenericReparseBuffer;
};
} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
+#define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
-#define _REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(_REPARSE_DATA_BUFFER, GenericReparseBuffer)
+#endif
class FileHandleWrapper
@@ -154,35 +164,31 @@ Link createJunction(const QString &linkPath, const QString &targetPath)
return Link(linkPath);
}
- TCHAR szDestDir[1024] = L"\\??\\"; //you need this to create valid unicode junctions
-
- QString normalizedTargetPath = QString(targetPath).replace(QLatin1Char('/'), QLatin1Char('\\'));
- //now we add the real absolute path
- StringCchCat(szDestDir, 1024, (wchar_t*)normalizedTargetPath.utf16());
+ const QString szDestDir = QString::fromLatin1("\\??\\").arg(targetPath).replace(QLatin1Char('/'),
+ QLatin1Char('\\'));
// Allocates a block of memory for an array of num elements(1) and initializes all its bits to zero.
- _REPARSE_DATA_BUFFER* reparseStructData = (_REPARSE_DATA_BUFFER*)calloc(1,
+ REPARSE_DATA_BUFFER* reparseStructData = (REPARSE_DATA_BUFFER*)calloc(1,
MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
- const size_t destMountPointBytes = lstrlen(szDestDir) * sizeof(WCHAR);
-
+ reparseStructData->Reserved = 0;
reparseStructData->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
+ reparseStructData->MountPointReparseBuffer.PrintNameLength = 0;
+ reparseStructData->MountPointReparseBuffer.SubstituteNameOffset = 0;
+ reparseStructData->MountPointReparseBuffer.SubstituteNameLength = szDestDir.length();
+ reparseStructData->MountPointReparseBuffer.PrintNameOffset = szDestDir.length() + sizeof(WCHAR);
- // Reserved(USHORT) + SubstituteNameOffset(USHORT) + SubstituteNameLength(USHORT)
- // + PrintNameOffset(USHORT) + PrintNameLength(USHORT) + PathBuffer[1](WCHAR)
uint spaceAfterGeneralData = sizeof(USHORT) * 5 + sizeof(WCHAR); //should be 12
- reparseStructData->ReparseDataLength = destMountPointBytes + spaceAfterGeneralData;
- reparseStructData->Reserved = 0;
- reparseStructData->MountPointReparseBuffer.SubstituteNameOffset = 0;
- reparseStructData->MountPointReparseBuffer.SubstituteNameLength = destMountPointBytes;
- // + sizeof(WCHAR) means \0 termination at the end of the string
- reparseStructData->MountPointReparseBuffer.PrintNameOffset = destMountPointBytes + sizeof(WCHAR);
- reparseStructData->MountPointReparseBuffer.PrintNameLength = 0;
- StringCchCopy(reparseStructData->MountPointReparseBuffer.PathBuffer, 1024, szDestDir);
+ reparseStructData->ReparseDataLength = szDestDir.length() + spaceAfterGeneralData;
+#ifndef Q_CC_MINGW
+ StringCchCopy(reparseStructData->MountPointReparseBuffer.PathBuffer, 1024, (wchar_t*)szDestDir.utf16());
+#else
+ wcsncpy(reparseStructData->MountPointReparseBuffer.PathBuffer, (wchar_t*)szDestDir.utf16(), 1024);
+#endif
DWORD bytesReturned;
if (!::DeviceIoControl(dirHandle.handle(), FSCTL_SET_REPARSE_POINT, reparseStructData,
- reparseStructData->ReparseDataLength + _REPARSE_DATA_BUFFER_HEADER_SIZE, 0, 0,
+ reparseStructData->ReparseDataLength + REPARSE_DATA_BUFFER_HEADER_SIZE, 0, 0,
&bytesReturned, 0)) {
qWarning() << QString::fromLatin1("Could not set the reparse point: for '%1' to %2; error: %3"
).arg(linkPath, targetPath).arg(GetLastError());
@@ -193,7 +199,7 @@ Link createJunction(const QString &linkPath, const QString &targetPath)
bool removeJunction(const QString &path)
{
// Allocates a block of memory for an array of num elements(1) and initializes all its bits to zero.
- _REPARSE_DATA_BUFFER* reparseStructData = (_REPARSE_DATA_BUFFER*)calloc(1,
+ REPARSE_DATA_BUFFER* reparseStructData = (REPARSE_DATA_BUFFER*)calloc(1,
MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
reparseStructData->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;