equal
deleted
inserted
replaced
278 if (mode & S_IXOTH) |
278 if (mode & S_IXOTH) |
279 ret |= QFile::ExeOther; |
279 ret |= QFile::ExeOther; |
280 return ret; |
280 return ret; |
281 } |
281 } |
282 |
282 |
|
283 static QDateTime readMSDosDate(const uchar *src) |
|
284 { |
|
285 uint dosDate = readUInt(src); |
|
286 quint64 uDate; |
|
287 uDate = (quint64)(dosDate >> 16); |
|
288 uint tm_mday = (uDate & 0x1f); |
|
289 uint tm_mon = ((uDate & 0x1E0) >> 5); |
|
290 uint tm_year = (((uDate & 0x0FE00) >> 9) + 1980); |
|
291 uint tm_hour = ((dosDate & 0xF800) >> 11); |
|
292 uint tm_min = ((dosDate & 0x7E0) >> 5); |
|
293 uint tm_sec = ((dosDate & 0x1f) << 1); |
|
294 |
|
295 return QDateTime(QDate(tm_year, tm_mon, tm_mday), QTime(tm_hour, tm_min, tm_sec)); |
|
296 } |
|
297 |
283 struct LocalFileHeader |
298 struct LocalFileHeader |
284 { |
299 { |
285 uchar signature[4]; // 0x04034b50 |
300 uchar signature[4]; // 0x04034b50 |
286 uchar version_needed[2]; |
301 uchar version_needed[2]; |
287 uchar general_purpose_bits[2]; |
302 uchar general_purpose_bits[2]; |
341 QByteArray extra_field; |
356 QByteArray extra_field; |
342 QByteArray file_comment; |
357 QByteArray file_comment; |
343 }; |
358 }; |
344 |
359 |
345 QZipReader::FileInfo::FileInfo() |
360 QZipReader::FileInfo::FileInfo() |
346 : isDir(false), isFile(true), isSymLink(false), crc32(0), size(0) |
361 : isDir(false), isFile(false), isSymLink(false), crc32(0), size(0) |
347 { |
362 { |
348 } |
363 } |
349 |
364 |
350 QZipReader::FileInfo::~FileInfo() |
365 QZipReader::FileInfo::~FileInfo() |
351 { |
366 { |
363 isFile = other.isFile; |
378 isFile = other.isFile; |
364 isSymLink = other.isSymLink; |
379 isSymLink = other.isSymLink; |
365 permissions = other.permissions; |
380 permissions = other.permissions; |
366 crc32 = other.crc32; |
381 crc32 = other.crc32; |
367 size = other.size; |
382 size = other.size; |
|
383 lastModified = other.lastModified; |
368 return *this; |
384 return *this; |
|
385 } |
|
386 |
|
387 bool QZipReader::FileInfo::isValid() const |
|
388 { |
|
389 return isDir || isFile || isSymLink; |
369 } |
390 } |
370 |
391 |
371 class QZipPrivate |
392 class QZipPrivate |
372 { |
393 { |
373 public: |
394 public: |
401 fileInfo.isFile = S_ISREG(mode); |
422 fileInfo.isFile = S_ISREG(mode); |
402 fileInfo.isSymLink = S_ISLNK(mode); |
423 fileInfo.isSymLink = S_ISLNK(mode); |
403 fileInfo.permissions = modeToPermissions(mode); |
424 fileInfo.permissions = modeToPermissions(mode); |
404 fileInfo.crc32 = readUInt(header.h.crc_32); |
425 fileInfo.crc32 = readUInt(header.h.crc_32); |
405 fileInfo.size = readUInt(header.h.uncompressed_size); |
426 fileInfo.size = readUInt(header.h.uncompressed_size); |
|
427 fileInfo.lastModified = readMSDosDate(header.h.last_mod_file); |
406 } |
428 } |
407 |
429 |
408 class QZipReaderPrivate : public QZipPrivate |
430 class QZipReaderPrivate : public QZipPrivate |
409 { |
431 { |
410 public: |
432 public: |
748 close(); |
770 close(); |
749 delete d; |
771 delete d; |
750 } |
772 } |
751 |
773 |
752 /*! |
774 /*! |
|
775 Returns device used for reading zip archive. |
|
776 */ |
|
777 QIODevice* QZipReader::device() const |
|
778 { |
|
779 return d->device; |
|
780 } |
|
781 |
|
782 /*! |
753 Returns true if the user can read the file; otherwise returns false. |
783 Returns true if the user can read the file; otherwise returns false. |
754 */ |
784 */ |
755 bool QZipReader::isReadable() const |
785 bool QZipReader::isReadable() const |
756 { |
786 { |
757 return d->device->isReadable(); |
787 return d->device->isReadable(); |
794 } |
824 } |
795 |
825 |
796 /*! |
826 /*! |
797 Returns a FileInfo of an entry in the zipfile. |
827 Returns a FileInfo of an entry in the zipfile. |
798 The \a index is the index into the directoy listing of the zipfile. |
828 The \a index is the index into the directoy listing of the zipfile. |
|
829 Returns an invalid FileInfo if \a index is out of boundaries. |
799 |
830 |
800 \sa fileInfoList() |
831 \sa fileInfoList() |
801 */ |
832 */ |
802 QZipReader::FileInfo QZipReader::entryInfoAt(int index) const |
833 QZipReader::FileInfo QZipReader::entryInfoAt(int index) const |
803 { |
834 { |
804 d->scanFiles(); |
835 d->scanFiles(); |
805 QZipReader::FileInfo fi; |
836 QZipReader::FileInfo fi; |
806 d->fillFileInfo(index, fi); |
837 if (index >= 0 && index < d->fileHeaders.count()) |
|
838 d->fillFileInfo(index, fi); |
807 return fi; |
839 return fi; |
808 } |
840 } |
809 |
841 |
810 /*! |
842 /*! |
811 Fetch the file contents from the zip archive and return the uncompressed bytes. |
843 Fetch the file contents from the zip archive and return the uncompressed bytes. |
1020 close(); |
1052 close(); |
1021 delete d; |
1053 delete d; |
1022 } |
1054 } |
1023 |
1055 |
1024 /*! |
1056 /*! |
|
1057 Returns device used for writing zip archive. |
|
1058 */ |
|
1059 QIODevice* QZipWriter::device() const |
|
1060 { |
|
1061 return d->device; |
|
1062 } |
|
1063 |
|
1064 /*! |
1025 Returns true if the user can write to the archive; otherwise returns false. |
1065 Returns true if the user can write to the archive; otherwise returns false. |
1026 */ |
1066 */ |
1027 bool QZipWriter::isWritable() const |
1067 bool QZipWriter::isWritable() const |
1028 { |
1068 { |
1029 return d->device->isWritable(); |
1069 return d->device->isWritable(); |