File indexing completed on 2025-01-26 04:24:54
0001 #ifndef QUA_ZIPFILEINFO_H 0002 #define QUA_ZIPFILEINFO_H 0003 0004 /* 0005 Copyright (C) 2005-2014 Sergey A. Tachenov 0006 0007 This file is part of QuaZIP. 0008 0009 QuaZIP is free software: you can redistribute it and/or modify 0010 it under the terms of the GNU Lesser General Public License as published by 0011 the Free Software Foundation, either version 2.1 of the License, or 0012 (at your option) any later version. 0013 0014 QuaZIP is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 GNU Lesser General Public License for more details. 0018 0019 You should have received a copy of the GNU Lesser General Public License 0020 along with QuaZIP. If not, see <http://www.gnu.org/licenses/>. 0021 0022 See COPYING file for the full LGPL text. 0023 0024 Original ZIP package is copyrighted by Gilles Vollant and contributors, 0025 see quazip/(un)zip.h files for details. Basically it's the zlib license. 0026 */ 0027 0028 #include <QByteArray> 0029 #include <QDateTime> 0030 #include <QFile> 0031 0032 #include "quazip_global.h" 0033 0034 /// Information about a file inside archive. 0035 /** 0036 * \deprecated Use QuaZipFileInfo64 instead. Not only it supports large files, 0037 * but also more convenience methods as well. 0038 * 0039 * Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to 0040 * fill this structure. */ 0041 struct QUAZIP_EXPORT QuaZipFileInfo { 0042 /// File name. 0043 QString name; 0044 /// Version created by. 0045 quint16 versionCreated; 0046 /// Version needed to extract. 0047 quint16 versionNeeded; 0048 /// General purpose flags. 0049 quint16 flags; 0050 /// Compression method. 0051 quint16 method; 0052 /// Last modification date and time. 0053 QDateTime dateTime; 0054 /// CRC. 0055 quint32 crc; 0056 /// Compressed file size. 0057 quint32 compressedSize; 0058 /// Uncompressed file size. 0059 quint32 uncompressedSize; 0060 /// Disk number start. 0061 quint16 diskNumberStart; 0062 /// Internal file attributes. 0063 quint16 internalAttr; 0064 /// External file attributes. 0065 quint32 externalAttr; 0066 /// Comment. 0067 QString comment; 0068 /// Extra field. 0069 QByteArray extra; 0070 /// Get the file permissions. 0071 /** 0072 Returns the high 16 bits of external attributes converted to 0073 QFile::Permissions. 0074 */ 0075 QFile::Permissions getPermissions() const; 0076 }; 0077 0078 /// Information about a file inside archive (with zip64 support). 0079 /** Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to 0080 * fill this structure. */ 0081 struct QUAZIP_EXPORT QuaZipFileInfo64 { 0082 /// File name. 0083 QString name; 0084 /// Version created by. 0085 quint16 versionCreated; 0086 /// Version needed to extract. 0087 quint16 versionNeeded; 0088 /// General purpose flags. 0089 quint16 flags; 0090 /// Compression method. 0091 quint16 method; 0092 /// Last modification date and time. 0093 /** 0094 * This is the time stored in the standard ZIP header. This format only allows 0095 * to store time with 2-second precision, so the seconds will always be even 0096 * and the milliseconds will always be zero. If you need more precise 0097 * date and time, you can try to call the getNTFSmTime() function or 0098 * its siblings, provided that the archive itself contains these NTFS times. 0099 */ 0100 QDateTime dateTime; 0101 /// CRC. 0102 quint32 crc; 0103 /// Compressed file size. 0104 quint64 compressedSize; 0105 /// Uncompressed file size. 0106 quint64 uncompressedSize; 0107 /// Disk number start. 0108 quint16 diskNumberStart; 0109 /// Internal file attributes. 0110 quint16 internalAttr; 0111 /// External file attributes. 0112 quint32 externalAttr; 0113 /// Comment. 0114 QString comment; 0115 /// Extra field. 0116 QByteArray extra; 0117 /// Get the file permissions. 0118 /** 0119 Returns the high 16 bits of external attributes converted to 0120 QFile::Permissions. 0121 */ 0122 QFile::Permissions getPermissions() const; 0123 /// Converts to QuaZipFileInfo 0124 /** 0125 If any of the fields are greater than 0xFFFFFFFFu, they are set to 0126 0xFFFFFFFFu exactly, not just truncated. This function should be mainly used 0127 for compatibility with the old code expecting QuaZipFileInfo, in the cases 0128 when it's impossible or otherwise unadvisable (due to ABI compatibility 0129 reasons, for example) to modify that old code to use QuaZipFileInfo64. 0130 0131 \return \c true if all fields converted correctly, \c false if an overflow 0132 occured. 0133 */ 0134 bool toQuaZipFileInfo(QuaZipFileInfo &info) const; 0135 /// Returns the NTFS modification time 0136 /** 0137 * The getNTFS*Time() functions only work if there is an NTFS extra field 0138 * present. Otherwise, they all return invalid null timestamps. 0139 * @param fineTicks If not NULL, the fractional part of milliseconds returned 0140 * there, measured in 100-nanosecond ticks. Will be set to 0141 * zero if there is no NTFS extra field. 0142 * @sa dateTime 0143 * @sa getNTFSaTime() 0144 * @sa getNTFScTime() 0145 * @return The NTFS modification time, UTC 0146 */ 0147 QDateTime getNTFSmTime(int *fineTicks = NULL) const; 0148 /// Returns the NTFS access time 0149 /** 0150 * The getNTFS*Time() functions only work if there is an NTFS extra field 0151 * present. Otherwise, they all return invalid null timestamps. 0152 * @param fineTicks If not NULL, the fractional part of milliseconds returned 0153 * there, measured in 100-nanosecond ticks. Will be set to 0154 * zero if there is no NTFS extra field. 0155 * @sa dateTime 0156 * @sa getNTFSmTime() 0157 * @sa getNTFScTime() 0158 * @return The NTFS access time, UTC 0159 */ 0160 QDateTime getNTFSaTime(int *fineTicks = NULL) const; 0161 /// Returns the NTFS creation time 0162 /** 0163 * The getNTFS*Time() functions only work if there is an NTFS extra field 0164 * present. Otherwise, they all return invalid null timestamps. 0165 * @param fineTicks If not NULL, the fractional part of milliseconds returned 0166 * there, measured in 100-nanosecond ticks. Will be set to 0167 * zero if there is no NTFS extra field. 0168 * @sa dateTime 0169 * @sa getNTFSmTime() 0170 * @sa getNTFSaTime() 0171 * @return The NTFS creation time, UTC 0172 */ 0173 QDateTime getNTFScTime(int *fineTicks = NULL) const; 0174 /// Checks whether the file is encrypted. 0175 bool isEncrypted() const {return (flags & 1) != 0;} 0176 }; 0177 0178 #endif