| 1 | 
 #ifndef QUA_ZIPFILEINFO_H | 
 
 
 
 
 
 | 2 | 
 #define QUA_ZIPFILEINFO_H | 
 
 
 
 
 
 | 3 | 
  | 
 
 
 
 
 
 | 4 | 
 /* | 
 
 
 
 
 
 | 5 | 
 Copyright (C) 2005-2014 Sergey A. Tachenov | 
 
 
 
 
 
 | 6 | 
  | 
 
 
 
 
 
 | 7 | 
 This file is part of QuaZIP. | 
 
 
 
 
 
 | 8 | 
  | 
 
 
 
 
 
 | 9 | 
 QuaZIP is free software: you can redistribute it and/or modify | 
 
 
 
 
 
 | 10 | 
 it under the terms of the GNU Lesser General Public License as published by | 
 
 
 
 
 
 | 11 | 
 the Free Software Foundation, either version 2.1 of the License, or | 
 
 
 
 
 
 | 12 | 
 (at your option) any later version. | 
 
 
 
 
 
 | 13 | 
  | 
 
 
 
 
 
 | 14 | 
 QuaZIP is distributed in the hope that it will be useful, | 
 
 
 
 
 
 | 15 | 
 but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 
 
 
 
 
 | 16 | 
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 
 
 
 
 
 | 17 | 
 GNU Lesser General Public License for more details. | 
 
 
 
 
 
 | 18 | 
  | 
 
 
 
 
 
 | 19 | 
 You should have received a copy of the GNU Lesser General Public License | 
 
 
 
 
 
 | 20 | 
 along with QuaZIP.  If not, see <http://www.gnu.org/licenses/>. | 
 
 
 
 
 
 | 21 | 
  | 
 
 
 
 
 
 | 22 | 
 See COPYING file for the full LGPL text. | 
 
 
 
 
 
 | 23 | 
  | 
 
 
 
 
 
 | 24 | 
 Original ZIP package is copyrighted by Gilles Vollant and contributors, | 
 
 
 
 
 
 | 25 | 
 see quazip/(un)zip.h files for details. Basically it's the zlib license. | 
 
 
 
 
 
 | 26 | 
 */ | 
 
 
 
 
 
 | 27 | 
  | 
 
 
 
 
 
 | 28 | 
 #include <QByteArray> | 
 
 
 
 
 
 | 29 | 
 #include <QDateTime> | 
 
 
 
 
 
 | 30 | 
 #include <QFile> | 
 
 
 
 
 
 | 31 | 
  | 
 
 
 
 
 
 | 32 | 
 #include "quazip_global.h" | 
 
 
 
 
 
 | 33 | 
  | 
 
 
 
 
 
 | 34 | 
 /// Information about a file inside archive. | 
 
 
 
 
 
 | 35 | 
 /** | 
 
 
 
 
 
 | 36 | 
  * \deprecated Use QuaZipFileInfo64 instead. Not only it supports large files, | 
 
 
 
 
 
 | 37 | 
  * but also more convenience methods as well. | 
 
 
 
 
 
 | 38 | 
  * | 
 
 
 
 
 
 | 39 | 
  * Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to | 
 
 
 
 
 
 | 40 | 
  * fill this structure. */ | 
 
 
 
 
 
 | 41 | 
 struct QUAZIP_EXPORT QuaZipFileInfo { | 
 
 
 
 
 
 | 42 | 
   /// File name. | 
 
 
 
 
 
 | 43 | 
   QString name; | 
 
 
 
 
 
 | 44 | 
   /// Version created by. | 
 
 
 
 
 
 | 45 | 
   quint16 versionCreated; | 
 
 
 
 
 
 | 46 | 
   /// Version needed to extract. | 
 
 
 
 
 
 | 47 | 
   quint16 versionNeeded; | 
 
 
 
 
 
 | 48 | 
   /// General purpose flags. | 
 
 
 
 
 
 | 49 | 
   quint16 flags; | 
 
 
 
 
 
 | 50 | 
   /// Compression method. | 
 
 
 
 
 
 | 51 | 
   quint16 method; | 
 
 
 
 
 
 | 52 | 
   /// Last modification date and time. | 
 
 
 
 
 
 | 53 | 
   QDateTime dateTime; | 
 
 
 
 
 
 | 54 | 
   /// CRC. | 
 
 
 
 
 
 | 55 | 
   quint32 crc; | 
 
 
 
 
 
 | 56 | 
   /// Compressed file size. | 
 
 
 
 
 
 | 57 | 
   quint32 compressedSize; | 
 
 
 
 
 
 | 58 | 
   /// Uncompressed file size. | 
 
 
 
 
 
 | 59 | 
   quint32 uncompressedSize; | 
 
 
 
 
 
 | 60 | 
   /// Disk number start. | 
 
 
 
 
 
 | 61 | 
   quint16 diskNumberStart; | 
 
 
 
 
 
 | 62 | 
   /// Internal file attributes. | 
 
 
 
 
 
 | 63 | 
   quint16 internalAttr; | 
 
 
 
 
 
 | 64 | 
   /// External file attributes. | 
 
 
 
 
 
 | 65 | 
   quint32 externalAttr; | 
 
 
 
 
 
 | 66 | 
   /// Comment. | 
 
 
 
 
 
 | 67 | 
   QString comment; | 
 
 
 
 
 
 | 68 | 
   /// Extra field. | 
 
 
 
 
 
 | 69 | 
   QByteArray extra; | 
 
 
 
 
 
 | 70 | 
   /// Get the file permissions. | 
 
 
 
 
 
 | 71 | 
   /** | 
 
 
 
 
 
 | 72 | 
     Returns the high 16 bits of external attributes converted to | 
 
 
 
 
 
 | 73 | 
     QFile::Permissions. | 
 
 
 
 
 
 | 74 | 
     */ | 
 
 
 
 
 
 | 75 | 
   QFile::Permissions getPermissions() const; | 
 
 
 
 
 
 | 76 | 
 }; | 
 
 
 
 
 
 | 77 | 
  | 
 
 
 
 
 
 | 78 | 
 /// Information about a file inside archive (with zip64 support). | 
 
 
 
 
 
 | 79 | 
 /** Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to | 
 
 
 
 
 
 | 80 | 
  * fill this structure. */ | 
 
 
 
 
 
 | 81 | 
 struct QUAZIP_EXPORT QuaZipFileInfo64 { | 
 
 
 
 
 
 | 82 | 
   /// File name. | 
 
 
 
 
 
 | 83 | 
   QString name; | 
 
 
 
 
 
 | 84 | 
   /// Version created by. | 
 
 
 
 
 
 | 85 | 
   quint16 versionCreated; | 
 
 
 
 
 
 | 86 | 
   /// Version needed to extract. | 
 
 
 
 
 
 | 87 | 
   quint16 versionNeeded; | 
 
 
 
 
 
 | 88 | 
   /// General purpose flags. | 
 
 
 
 
 
 | 89 | 
   quint16 flags; | 
 
 
 
 
 
 | 90 | 
   /// Compression method. | 
 
 
 
 
 
 | 91 | 
   quint16 method; | 
 
 
 
 
 
 | 92 | 
   /// Last modification date and time. | 
 
 
 
 
 
 | 93 | 
   /** | 
 
 
 
 
 
 | 94 | 
    * This is the time stored in the standard ZIP header. This format only allows | 
 
 
 
 
 
 | 95 | 
    * to store time with 2-second precision, so the seconds will always be even | 
 
 
 
 
 
 | 96 | 
    * and the milliseconds will always be zero. If you need more precise | 
 
 
 
 
 
 | 97 | 
    * date and time, you can try to call the getNTFSmTime() function or | 
 
 
 
 
 
 | 98 | 
    * its siblings, provided that the archive itself contains these NTFS times. | 
 
 
 
 
 
 | 99 | 
    */ | 
 
 
 
 
 
 | 100 | 
   QDateTime dateTime; | 
 
 
 
 
 
 | 101 | 
   /// CRC. | 
 
 
 
 
 
 | 102 | 
   quint32 crc; | 
 
 
 
 
 
 | 103 | 
   /// Compressed file size. | 
 
 
 
 
 
 | 104 | 
   quint64 compressedSize; | 
 
 
 
 
 
 | 105 | 
   /// Uncompressed file size. | 
 
 
 
 
 
 | 106 | 
   quint64 uncompressedSize; | 
 
 
 
 
 
 | 107 | 
   /// Disk number start. | 
 
 
 
 
 
 | 108 | 
   quint16 diskNumberStart; | 
 
 
 
 
 
 | 109 | 
   /// Internal file attributes. | 
 
 
 
 
 
 | 110 | 
   quint16 internalAttr; | 
 
 
 
 
 
 | 111 | 
   /// External file attributes. | 
 
 
 
 
 
 | 112 | 
   quint32 externalAttr; | 
 
 
 
 
 
 | 113 | 
   /// Comment. | 
 
 
 
 
 
 | 114 | 
   QString comment; | 
 
 
 
 
 
 | 115 | 
   /// Extra field. | 
 
 
 
 
 
 | 116 | 
   QByteArray extra; | 
 
 
 
 
 
 | 117 | 
   /// Get the file permissions. | 
 
 
 
 
 
 | 118 | 
   /** | 
 
 
 
 
 
 | 119 | 
     Returns the high 16 bits of external attributes converted to | 
 
 
 
 
 
 | 120 | 
     QFile::Permissions. | 
 
 
 
 
 
 | 121 | 
     */ | 
 
 
 
 
 
 | 122 | 
   QFile::Permissions getPermissions() const; | 
 
 
 
 
 
 | 123 | 
   /// Converts to QuaZipFileInfo | 
 
 
 
 
 
 | 124 | 
   /** | 
 
 
 
 
 
 | 125 | 
     If any of the fields are greater than 0xFFFFFFFFu, they are set to | 
 
 
 
 
 
 | 126 | 
     0xFFFFFFFFu exactly, not just truncated. This function should be mainly used | 
 
 
 
 
 
 | 127 | 
     for compatibility with the old code expecting QuaZipFileInfo, in the cases | 
 
 
 
 
 
 | 128 | 
     when it's impossible or otherwise unadvisable (due to ABI compatibility | 
 
 
 
 
 
 | 129 | 
     reasons, for example) to modify that old code to use QuaZipFileInfo64. | 
 
 
 
 
 
 | 130 | 
  | 
 
 
 
 
 
 | 131 | 
     \return \c true if all fields converted correctly, \c false if an overflow | 
 
 
 
 
 
 | 132 | 
     occured. | 
 
 
 
 
 
 | 133 | 
     */ | 
 
 
 
 
 
 | 134 | 
   bool toQuaZipFileInfo(QuaZipFileInfo &info) const; | 
 
 
 
 
 
 | 135 | 
   /// Returns the NTFS modification time | 
 
 
 
 
 
 | 136 | 
   /** | 
 
 
 
 
 
 | 137 | 
    * The getNTFS*Time() functions only work if there is an NTFS extra field | 
 
 
 
 
 
 | 138 | 
    * present. Otherwise, they all return invalid null timestamps. | 
 
 
 
 
 
 | 139 | 
    * @param fineTicks If not NULL, the fractional part of milliseconds returned | 
 
 
 
 
 
 | 140 | 
    *                  there, measured in 100-nanosecond ticks. Will be set to | 
 
 
 
 
 
 | 141 | 
    *                  zero if there is no NTFS extra field. | 
 
 
 
 
 
 | 142 | 
    * @sa dateTime | 
 
 
 
 
 
 | 143 | 
    * @sa getNTFSaTime() | 
 
 
 
 
 
 | 144 | 
    * @sa getNTFScTime() | 
 
 
 
 
 
 | 145 | 
    * @return The NTFS modification time, UTC | 
 
 
 
 
 
 | 146 | 
    */ | 
 
 
 
 
 
 | 147 | 
   QDateTime getNTFSmTime(int *fineTicks = NULL) const; | 
 
 
 
 
 
 | 148 | 
   /// Returns the NTFS access time | 
 
 
 
 
 
 | 149 | 
   /** | 
 
 
 
 
 
 | 150 | 
    * The getNTFS*Time() functions only work if there is an NTFS extra field | 
 
 
 
 
 
 | 151 | 
    * present. Otherwise, they all return invalid null timestamps. | 
 
 
 
 
 
 | 152 | 
    * @param fineTicks If not NULL, the fractional part of milliseconds returned | 
 
 
 
 
 
 | 153 | 
    *                  there, measured in 100-nanosecond ticks. Will be set to | 
 
 
 
 
 
 | 154 | 
    *                  zero if there is no NTFS extra field. | 
 
 
 
 
 
 | 155 | 
    * @sa dateTime | 
 
 
 
 
 
 | 156 | 
    * @sa getNTFSmTime() | 
 
 
 
 
 
 | 157 | 
    * @sa getNTFScTime() | 
 
 
 
 
 
 | 158 | 
    * @return The NTFS access time, UTC | 
 
 
 
 
 
 | 159 | 
    */ | 
 
 
 
 
 
 | 160 | 
   QDateTime getNTFSaTime(int *fineTicks = NULL) const; | 
 
 
 
 
 
 | 161 | 
   /// Returns the NTFS creation time | 
 
 
 
 
 
 | 162 | 
   /** | 
 
 
 
 
 
 | 163 | 
    * The getNTFS*Time() functions only work if there is an NTFS extra field | 
 
 
 
 
 
 | 164 | 
    * present. Otherwise, they all return invalid null timestamps. | 
 
 
 
 
 
 | 165 | 
    * @param fineTicks If not NULL, the fractional part of milliseconds returned | 
 
 
 
 
 
 | 166 | 
    *                  there, measured in 100-nanosecond ticks. Will be set to | 
 
 
 
 
 
 | 167 | 
    *                  zero if there is no NTFS extra field. | 
 
 
 
 
 
 | 168 | 
    * @sa dateTime | 
 
 
 
 
 
 | 169 | 
    * @sa getNTFSmTime() | 
 
 
 
 
 
 | 170 | 
    * @sa getNTFSaTime() | 
 
 
 
 
 
 | 171 | 
    * @return The NTFS creation time, UTC | 
 
 
 
 
 
 | 172 | 
    */ | 
 
 
 
 
 
 | 173 | 
   QDateTime getNTFScTime(int *fineTicks = NULL) const; | 
 
 
 
 
 
 | 174 | 
   /// Checks whether the file is encrypted. | 
 
 
 
 
 
 | 175 | 
   bool isEncrypted() const {return (flags & 1) != 0;} | 
 
 
 
 
 
 | 176 | 
 }; | 
 
 
 
 
 
 | 177 | 
  | 
 
 
 
 
 
 | 178 | 
 #endif |