summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qzip.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-03-15 04:57:33 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-03-15 04:57:33 (GMT)
commitf5fa6d1955f4fc49e7bcf2bb1ef905d5927fe158 (patch)
tree2929fc2f4afcf1fca05b33dd30ddfc9b86142b96 /src/gui/text/qzip.cpp
parent065f26ef3996368ba67ff5d8e34b20106c359a95 (diff)
parent1edf1e7c80857165c2cdc01c97658518a20bb806 (diff)
downloadQt-f5fa6d1955f4fc49e7bcf2bb1ef905d5927fe158.zip
Qt-f5fa6d1955f4fc49e7bcf2bb1ef905d5927fe158.tar.gz
Qt-f5fa6d1955f4fc49e7bcf2bb1ef905d5927fe158.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (56 commits) Remove NetworkManager test-bed application. Remove configure test for NetworkManager. Fix QDir::entryList regression Add DEFINES to mingw32/windres.exe command line. Fix up whitespace in license headers. Fix SetDialogPreference build error on Symbian. get known wifi networks a more complicated way, but without accessing Only enable BM by default in QNAM for appropriate platforms. fix crash on 10.6 with no wifi interface Fix creation of QNetworkSession. Make QNetworkConfigurationManager and QNetworkConfiguration threadsafe. remove qt_winQString2MB() and qt_winMB2QString() Fix include() path in qimportbase.pri Fix qmake crash on Windows Compile Revert some unfinished changes. Fix compilation with namespaced Qt Add a placeholder text into the new search lineedit Ui improvements to QDBusViewer. Make double-clicking a d-bus method work again ...
Diffstat (limited to 'src/gui/text/qzip.cpp')
-rw-r--r--src/gui/text/qzip.cpp44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp
index d30c996..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
@@ -343,7 +358,7 @@ struct FileHeader
};
QZipReader::FileInfo::FileInfo()
- : isDir(false), isFile(true), isSymLink(false), crc32(0), size(0)
+ : isDir(false), isFile(false), isSymLink(false), crc32(0), size(0)
{
}
@@ -365,9 +380,15 @@ QZipReader::FileInfo& QZipReader::FileInfo::operator=(const FileInfo &other)
permissions = other.permissions;
crc32 = other.crc32;
size = other.size;
+ lastModified = other.lastModified;
return *this;
}
+bool QZipReader::FileInfo::isValid() const
+{
+ return isDir || isFile || isSymLink;
+}
+
class QZipPrivate
{
public:
@@ -403,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
@@ -750,6 +772,14 @@ QZipReader::~QZipReader()
}
/*!
+ Returns device used for reading zip archive.
+*/
+QIODevice* QZipReader::device() const
+{
+ return d->device;
+}
+
+/*!
Returns true if the user can read the file; otherwise returns false.
*/
bool QZipReader::isReadable() const
@@ -796,6 +826,7 @@ int QZipReader::count() const
/*!
Returns a FileInfo of an entry in the zipfile.
The \a index is the index into the directoy listing of the zipfile.
+ Returns an invalid FileInfo if \a index is out of boundaries.
\sa fileInfoList()
*/
@@ -803,7 +834,8 @@ QZipReader::FileInfo QZipReader::entryInfoAt(int index) const
{
d->scanFiles();
QZipReader::FileInfo fi;
- d->fillFileInfo(index, fi);
+ if (index >= 0 && index < d->fileHeaders.count())
+ d->fillFileInfo(index, fi);
return fi;
}
@@ -1022,6 +1054,14 @@ QZipWriter::~QZipWriter()
}
/*!
+ Returns device used for writing zip archive.
+*/
+QIODevice* QZipWriter::device() const
+{
+ return d->device;
+}
+
+/*!
Returns true if the user can write to the archive; otherwise returns false.
*/
bool QZipWriter::isWritable() const