summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2010-03-10 11:30:10 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2010-03-10 11:30:10 (GMT)
commit9e50f610b44778b8baf64ef569c574f067cc62b8 (patch)
tree007f7d55cad42ab3dd8849d897593fb598f2ea17 /src
parentab7939145a83884ba618440db9d887b272d48bbe (diff)
downloadQt-9e50f610b44778b8baf64ef569c574f067cc62b8.zip
Qt-9e50f610b44778b8baf64ef569c574f067cc62b8.tar.gz
Qt-9e50f610b44778b8baf64ef569c574f067cc62b8.tar.bz2
Add ability to read last mod.time for zip entry.
Reviewed-by: Benjamin Poulain <benjamin.poulain@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qzip.cpp17
-rw-r--r--src/gui/text/qzipreader_p.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp
index e2e0fb6..6f099a9 100644
--- a/src/gui/text/qzip.cpp
+++ b/src/gui/text/qzip.cpp
@@ -280,6 +280,21 @@ static QFile::Permissions modeToPermissions(quint32 mode)
return ret;
}
+static QDateTime readMSDosDate(const uchar *src)
+{
+ uint dosDate = readUInt(src);
+ quint64 uDate;
+ uDate = (quint64)(dosDate >> 16);
+ uint tm_mday = (uDate & 0x1f);
+ uint tm_mon = ((uDate & 0x1E0) >> 5);
+ uint tm_year = (((uDate & 0x0FE00) >> 9) + 1980);
+ uint tm_hour = ((dosDate & 0xF800) >> 11);
+ uint tm_min = ((dosDate & 0x7E0) >> 5);
+ uint tm_sec = ((dosDate & 0x1f) << 1);
+
+ return QDateTime(QDate(tm_year, tm_mon, tm_mday), QTime(tm_hour, tm_min, tm_sec));
+}
+
struct LocalFileHeader
{
uchar signature[4]; // 0x04034b50
@@ -365,6 +380,7 @@ QZipReader::FileInfo& QZipReader::FileInfo::operator=(const FileInfo &other)
permissions = other.permissions;
crc32 = other.crc32;
size = other.size;
+ lastModified = other.lastModified;
return *this;
}
@@ -408,6 +424,7 @@ void QZipPrivate::fillFileInfo(int index, QZipReader::FileInfo &fileInfo) const
fileInfo.permissions = modeToPermissions(mode);
fileInfo.crc32 = readUInt(header.h.crc_32);
fileInfo.size = readUInt(header.h.uncompressed_size);
+ fileInfo.lastModified = readMSDosDate(header.h.last_mod_file);
}
class QZipReaderPrivate : public QZipPrivate
diff --git a/src/gui/text/qzipreader_p.h b/src/gui/text/qzipreader_p.h
index 4961e1c..6466a7b 100644
--- a/src/gui/text/qzipreader_p.h
+++ b/src/gui/text/qzipreader_p.h
@@ -55,6 +55,7 @@
// We mean it.
//
+#include <QtCore/qdatetime.h>
#include <QtCore/qfile.h>
#include <QtCore/qstring.h>
@@ -89,6 +90,7 @@ public:
QFile::Permissions permissions;
uint crc32;
qint64 size;
+ QDateTime lastModified;
void *d;
};