Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/text/qzip.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    281281}
    282282
     283static 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
    283298struct LocalFileHeader
    284299{
     
    344359
    345360QZipReader::FileInfo::FileInfo()
    346     : isDir(false), isFile(true), isSymLink(false), crc32(0), size(0)
     361    : isDir(false), isFile(false), isSymLink(false), crc32(0), size(0)
    347362{
    348363}
     
    366381    crc32 = other.crc32;
    367382    size = other.size;
     383    lastModified = other.lastModified;
    368384    return *this;
     385}
     386
     387bool QZipReader::FileInfo::isValid() const
     388{
     389    return isDir || isFile || isSymLink;
    369390}
    370391
     
    404425    fileInfo.crc32 = readUInt(header.h.crc_32);
    405426    fileInfo.size = readUInt(header.h.uncompressed_size);
     427    fileInfo.lastModified = readMSDosDate(header.h.last_mod_file);
    406428}
    407429
     
    751773
    752774/*!
     775    Returns device used for reading zip archive.
     776*/
     777QIODevice* QZipReader::device() const
     778{
     779    return d->device;
     780}
     781
     782/*!
    753783    Returns true if the user can read the file; otherwise returns false.
    754784*/
     
    796826/*!
    797827    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 directory listing of the zipfile.
     829    Returns an invalid FileInfo if \a index is out of boundaries.
    799830
    800831    \sa fileInfoList()
     
    804835    d->scanFiles();
    805836    QZipReader::FileInfo fi;
    806     d->fillFileInfo(index, fi);
     837    if (index >= 0 && index < d->fileHeaders.count())
     838        d->fillFileInfo(index, fi);
    807839    return fi;
    808840}
     
    10231055
    10241056/*!
     1057    Returns device used for writing zip archive.
     1058*/
     1059QIODevice* QZipWriter::device() const
     1060{
     1061    return d->device;
     1062}
     1063
     1064/*!
    10251065    Returns true if the user can write to the archive; otherwise returns false.
    10261066*/
Note: See TracChangeset for help on using the changeset viewer.