summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/7zip/7zip.pro2
-rw-r--r--src/libs/7zip/unix/CPP/include_windows/windows.h2
-rw-r--r--src/libs/7zip/unix/CPP/myWindows/myDateAndTime.cpp95
-rw-r--r--src/libs/installer/lib7z_facade.cpp12
4 files changed, 90 insertions, 21 deletions
diff --git a/src/libs/7zip/7zip.pro b/src/libs/7zip/7zip.pro
index d09cbf9a5..549778e67 100644
--- a/src/libs/7zip/7zip.pro
+++ b/src/libs/7zip/7zip.pro
@@ -1,6 +1,6 @@
include(../../../installerfw.pri)
-QT =
+QT = core
TARGET = 7z
TEMPLATE = lib
INCLUDEPATH += . ..
diff --git a/src/libs/7zip/unix/CPP/include_windows/windows.h b/src/libs/7zip/unix/CPP/include_windows/windows.h
index 871d9f3ae..5223e81ac 100644
--- a/src/libs/7zip/unix/CPP/include_windows/windows.h
+++ b/src/libs/7zip/unix/CPP/include_windows/windows.h
@@ -142,6 +142,8 @@ typedef struct _SYSTEMTIME {
extern "C" {
#endif
+BOOL WINAPI FileTimeToLocalFileTime(CONST FILETIME *,FILETIME *);
+//BOOL WINAPI LocalFileTimeToFileTime(CONST FILETIME *,FILETIME *);
BOOL WINAPI FileTimeToSystemTime(CONST FILETIME *,SYSTEMTIME *);
VOID WINAPI GetSystemTime(SYSTEMTIME *);
BOOL WINAPI SystemTimeToFileTime(const SYSTEMTIME*,FILETIME *);
diff --git a/src/libs/7zip/unix/CPP/myWindows/myDateAndTime.cpp b/src/libs/7zip/unix/CPP/myWindows/myDateAndTime.cpp
index 984954979..1773feb86 100644
--- a/src/libs/7zip/unix/CPP/myWindows/myDateAndTime.cpp
+++ b/src/libs/7zip/unix/CPP/myWindows/myDateAndTime.cpp
@@ -39,33 +39,108 @@
**
**************************************************************************/
-#include <time.h>
+#include <QDebug>
+#include <QDateTime>
#include "windows.h"
+void FileTimeToDateTime(const FILETIME *source, QDateTime *target)
+{
+ ULARGE_INTEGER store;
+ QDateTime tempDateTime(QDate(1601, 1, 1));
+
+ store.QuadPart = source->dwHighDateTime;
+ store.QuadPart = store.QuadPart << 32;
+ store.QuadPart += source->dwLowDateTime;
+
+ *target = tempDateTime.addMSecs(store.QuadPart / 10000);
+}
+
+void DateTimeToSystemTime(const QDateTime *source, SYSTEMTIME *target)
+{
+ target->wYear = source->date().year();
+ target->wMonth = source->date().month();
+ target->wDayOfWeek = source->date().dayOfWeek();
+ target->wDay = source->date().day();
+ target->wHour = source->time().hour();
+ target->wMinute = source->time().minute();
+ target->wSecond = source->time().second();
+ target->wMilliseconds = source->time().msec();
+}
+
+
BOOL WINAPI FileTimeToSystemTime(CONST FILETIME *source,SYSTEMTIME *target)
{
- // TODO: Implementation!
+ QDateTime tempDateTime;
+ FileTimeToDateTime(source, &tempDateTime);
+ DateTimeToSystemTime(&tempDateTime, target);
+
return TRUE;
}
-BOOLEAN WINAPI RtlTimeToSecondsSince1970(const LARGE_INTEGER *Time, DWORD *Seconds)
+BOOL WINAPI SystemTimeToFileTime(const SYSTEMTIME *source,FILETIME *target)
{
// TODO: Implementation!
+ // This doesn't seem to be called at all
+
+ qDebug() << "SystemTimeToFileTime";
+
+ target->dwHighDateTime = 0;
+ target->dwLowDateTime = 0;
+
+ qWarning() << Q_FUNC_INFO;
+
return TRUE;
}
-void WINAPI RtlSecondsSince1970ToFileTime(DWORD Seconds, FILETIME *ft)
+BOOL WINAPI FileTimeToLocalFileTime(CONST FILETIME *source,FILETIME *target)
{
- // TODO: Implementation!
+ target->dwHighDateTime = source->dwHighDateTime;
+ target->dwLowDateTime = source->dwLowDateTime;
+
+ QDateTime tempDateTime;
+ FileTimeToDateTime(source, &tempDateTime);
+
+ tempDateTime = tempDateTime.toLocalTime();
+
+ return TRUE;
}
-VOID WINAPI GetSystemTime(SYSTEMTIME *st)
+BOOLEAN WINAPI RtlTimeToSecondsSince1970(const LARGE_INTEGER *Time, DWORD *Seconds)
{
- // TODO: Implementation!
+ SYSTEMTIME tempSystemTime;
+ FILETIME fileTime;
+
+ fileTime.dwLowDateTime = Time->QuadPart;
+ fileTime.dwHighDateTime = Time->QuadPart >> 32;
+
+ FileTimeToSystemTime(&fileTime, &tempSystemTime);
+
+ QDate targetDate(tempSystemTime.wYear, tempSystemTime.wMonth, tempSystemTime.wDay);
+ QTime targetTime(tempSystemTime.wHour, tempSystemTime.wMinute, tempSystemTime.wSecond, tempSystemTime.wMilliseconds);
+ QDateTime targetDateTime(targetDate, targetTime, Qt::UTC);
+
+ quint64 secsSince1970 = targetDateTime.toMSecsSinceEpoch() / 1000;
+
+ *Seconds = secsSince1970;
+
+ return TRUE;
}
-BOOL WINAPI SystemTimeToFileTime(const SYSTEMTIME *source,FILETIME *target)
+void WINAPI RtlSecondsSince1970ToFileTime(DWORD Seconds, FILETIME *ft)
{
- // TODO: Implementation!
- return TRUE;
+ QDateTime fileTimeStartDate(QDate(1601, 1, 1));
+ quint64 hnseconds = Seconds;
+ QDateTime sourceDateTime = QDateTime::fromMSecsSinceEpoch(hnseconds * 1000);
+
+ hnseconds = fileTimeStartDate.msecsTo(sourceDateTime);
+ hnseconds *= 10000;
+
+ ft->dwLowDateTime = hnseconds;
+ ft->dwHighDateTime = hnseconds >> 32;
+}
+
+VOID WINAPI GetSystemTime(SYSTEMTIME *st)
+{
+ QDateTime nowDateTime = QDateTime::currentDateTimeUtc();
+ DateTimeToSystemTime(&nowDateTime, st);
}
diff --git a/src/libs/installer/lib7z_facade.cpp b/src/libs/installer/lib7z_facade.cpp
index 607d774ac..a818e9a61 100644
--- a/src/libs/installer/lib7z_facade.cpp
+++ b/src/libs/installer/lib7z_facade.cpp
@@ -257,10 +257,6 @@ static bool IsDST(const QDateTime& datetime = QDateTime())
static bool getFileTimeFromProperty(IInArchive* archive, int index, int propId, FILETIME *fileTime)
{
-// TODO: fix getFileTimeFromProperty under unix systems, till then just ignore the property
-#ifndef Q_OS_WIN
- return false;
-#endif
const NCOM::CPropVariant prop = readProperty(archive, index, propId);
if (prop.vt != VT_FILETIME) {
throw SevenZipException(QObject::tr("Property %1 for item %2 not of type VT_FILETIME but %3")
@@ -281,12 +277,8 @@ QDateTime getDateTimeProperty(IInArchive* archive, int index, int propId, const
return defaultValue;
FILETIME localFileTime;
-#ifndef Q_OS_UNIX
- if (!FileTimeToLocalFileTime(&fileTime, &localFileTime))
- throw SevenZipException(QObject::tr("Could not convert file time to local time"));
-#else
- localFileTime = fileTime;
-#endif
+ if (!FileTimeToLocalFileTime(&fileTime, &localFileTime))
+ throw SevenZipException(QObject::tr("Could not convert file time to local time"));
SYSTEMTIME st;
if (!BOOLToBool(FileTimeToSystemTime(&localFileTime, &st)))