diff options
Diffstat (limited to 'utils/rbutilqt/quazip/quazipfileinfo.h')
-rw-r--r-- | utils/rbutilqt/quazip/quazipfileinfo.h | 226 |
1 files changed, 226 insertions, 0 deletions
diff --git a/utils/rbutilqt/quazip/quazipfileinfo.h b/utils/rbutilqt/quazip/quazipfileinfo.h new file mode 100644 index 0000000000..43665b4ac2 --- /dev/null +++ b/utils/rbutilqt/quazip/quazipfileinfo.h | |||
@@ -0,0 +1,226 @@ | |||
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 <QtCore/QByteArray> | ||
29 | #include <QtCore/QDateTime> | ||
30 | #include <QtCore/QFile> | ||
31 | #include <QtCore/QHash> | ||
32 | |||
33 | #include "quazip_global.h" | ||
34 | |||
35 | /// The typedef to store extra field parse results | ||
36 | typedef QHash<quint16, QList<QByteArray> > QuaExtraFieldHash; | ||
37 | |||
38 | /// Information about a file inside archive. | ||
39 | /** | ||
40 | * \deprecated Use QuaZipFileInfo64 instead. Not only it supports large files, | ||
41 | * but also more convenience methods as well. | ||
42 | * | ||
43 | * Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to | ||
44 | * fill this structure. */ | ||
45 | struct QUAZIP_EXPORT QuaZipFileInfo { | ||
46 | /// File name. | ||
47 | QString name; | ||
48 | /// Version created by. | ||
49 | quint16 versionCreated; | ||
50 | /// Version needed to extract. | ||
51 | quint16 versionNeeded; | ||
52 | /// General purpose flags. | ||
53 | quint16 flags; | ||
54 | /// Compression method. | ||
55 | quint16 method; | ||
56 | /// Last modification date and time. | ||
57 | QDateTime dateTime; | ||
58 | /// CRC. | ||
59 | quint32 crc; | ||
60 | /// Compressed file size. | ||
61 | quint32 compressedSize; | ||
62 | /// Uncompressed file size. | ||
63 | quint32 uncompressedSize; | ||
64 | /// Disk number start. | ||
65 | quint16 diskNumberStart; | ||
66 | /// Internal file attributes. | ||
67 | quint16 internalAttr; | ||
68 | /// External file attributes. | ||
69 | quint32 externalAttr; | ||
70 | /// Comment. | ||
71 | QString comment; | ||
72 | /// Extra field. | ||
73 | QByteArray extra; | ||
74 | /// Get the file permissions. | ||
75 | /** | ||
76 | Returns the high 16 bits of external attributes converted to | ||
77 | QFile::Permissions. | ||
78 | */ | ||
79 | QFile::Permissions getPermissions() const; | ||
80 | }; | ||
81 | |||
82 | /// Information about a file inside archive (with zip64 support). | ||
83 | /** Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to | ||
84 | * fill this structure. */ | ||
85 | struct QUAZIP_EXPORT QuaZipFileInfo64 { | ||
86 | /// File name. | ||
87 | QString name; | ||
88 | /// Version created by. | ||
89 | quint16 versionCreated; | ||
90 | /// Version needed to extract. | ||
91 | quint16 versionNeeded; | ||
92 | /// General purpose flags. | ||
93 | quint16 flags; | ||
94 | /// Compression method. | ||
95 | quint16 method; | ||
96 | /// Last modification date and time. | ||
97 | /** | ||
98 | * This is the time stored in the standard ZIP header. This format only allows | ||
99 | * to store time with 2-second precision, so the seconds will always be even | ||
100 | * and the milliseconds will always be zero. If you need more precise | ||
101 | * date and time, you can try to call the getNTFSmTime() function or | ||
102 | * its siblings, provided that the archive itself contains these NTFS times. | ||
103 | */ | ||
104 | QDateTime dateTime; | ||
105 | /// CRC. | ||
106 | quint32 crc; | ||
107 | /// Compressed file size. | ||
108 | quint64 compressedSize; | ||
109 | /// Uncompressed file size. | ||
110 | quint64 uncompressedSize; | ||
111 | /// Disk number start. | ||
112 | quint16 diskNumberStart; | ||
113 | /// Internal file attributes. | ||
114 | quint16 internalAttr; | ||
115 | /// External file attributes. | ||
116 | quint32 externalAttr; | ||
117 | /// Comment. | ||
118 | QString comment; | ||
119 | /// Extra field. | ||
120 | QByteArray extra; | ||
121 | /// Get the file permissions. | ||
122 | /** | ||
123 | Returns the high 16 bits of external attributes converted to | ||
124 | QFile::Permissions. | ||
125 | */ | ||
126 | QFile::Permissions getPermissions() const; | ||
127 | /// Converts to QuaZipFileInfo | ||
128 | /** | ||
129 | If any of the fields are greater than 0xFFFFFFFFu, they are set to | ||
130 | 0xFFFFFFFFu exactly, not just truncated. This function should be mainly used | ||
131 | for compatibility with the old code expecting QuaZipFileInfo, in the cases | ||
132 | when it's impossible or otherwise unadvisable (due to ABI compatibility | ||
133 | reasons, for example) to modify that old code to use QuaZipFileInfo64. | ||
134 | |||
135 | \return \c true if all fields converted correctly, \c false if an overflow | ||
136 | occured. | ||
137 | */ | ||
138 | bool toQuaZipFileInfo(QuaZipFileInfo &info) const; | ||
139 | /// Returns the NTFS modification time | ||
140 | /** | ||
141 | * The getNTFS*Time() functions only work if there is an NTFS extra field | ||
142 | * present. Otherwise, they all return invalid null timestamps. | ||
143 | * @param fineTicks If not NULL, the fractional part of milliseconds returned | ||
144 | * there, measured in 100-nanosecond ticks. Will be set to | ||
145 | * zero if there is no NTFS extra field. | ||
146 | * @sa dateTime | ||
147 | * @sa getNTFSaTime() | ||
148 | * @sa getNTFScTime() | ||
149 | * @return The NTFS modification time, UTC | ||
150 | */ | ||
151 | QDateTime getNTFSmTime(int *fineTicks = NULL) const; | ||
152 | /// Returns the NTFS access time | ||
153 | /** | ||
154 | * The getNTFS*Time() functions only work if there is an NTFS extra field | ||
155 | * present. Otherwise, they all return invalid null timestamps. | ||
156 | * @param fineTicks If not NULL, the fractional part of milliseconds returned | ||
157 | * there, measured in 100-nanosecond ticks. Will be set to | ||
158 | * zero if there is no NTFS extra field. | ||
159 | * @sa dateTime | ||
160 | * @sa getNTFSmTime() | ||
161 | * @sa getNTFScTime() | ||
162 | * @return The NTFS access time, UTC | ||
163 | */ | ||
164 | QDateTime getNTFSaTime(int *fineTicks = NULL) const; | ||
165 | /// Returns the NTFS creation time | ||
166 | /** | ||
167 | * The getNTFS*Time() functions only work if there is an NTFS extra field | ||
168 | * present. Otherwise, they all return invalid null timestamps. | ||
169 | * @param fineTicks If not NULL, the fractional part of milliseconds returned | ||
170 | * there, measured in 100-nanosecond ticks. Will be set to | ||
171 | * zero if there is no NTFS extra field. | ||
172 | * @sa dateTime | ||
173 | * @sa getNTFSmTime() | ||
174 | * @sa getNTFSaTime() | ||
175 | * @return The NTFS creation time, UTC | ||
176 | */ | ||
177 | QDateTime getNTFScTime(int *fineTicks = NULL) const; | ||
178 | /// Returns the extended modification timestamp | ||
179 | /** | ||
180 | * The getExt*Time() functions only work if there is an extended timestamp | ||
181 | * extra field (ID 0x5455) present. Otherwise, they all return invalid null | ||
182 | * timestamps. | ||
183 | * | ||
184 | * QuaZipFileInfo64 only contains the modification time because it's extracted | ||
185 | * from @ref extra, which contains the global extra field, and access and | ||
186 | * creation time are in the local header which can be accessed through | ||
187 | * @ref QuaZipFile. | ||
188 | * | ||
189 | * @sa dateTime | ||
190 | * @sa QuaZipFile::getExtModTime() | ||
191 | * @sa QuaZipFile::getExtAcTime() | ||
192 | * @sa QuaZipFile::getExtCrTime() | ||
193 | * @return The extended modification time, UTC | ||
194 | */ | ||
195 | QDateTime getExtModTime() const; | ||
196 | /// Checks whether the file is encrypted. | ||
197 | bool isEncrypted() const {return (flags & 1) != 0;} | ||
198 | /// Parses extra field | ||
199 | /** | ||
200 | * The returned hash table contains a list of data blocks for every header ID | ||
201 | * in the provided extra field. The number of data blocks in a hash table value | ||
202 | * equals to the number of occurrences of the appropriate header id. In most cases, | ||
203 | * a block with a specific header ID only occurs once, and therefore the returned | ||
204 | * hash table will contain a list consisting of a single element for that header ID. | ||
205 | * | ||
206 | * @param extraField extra field to parse | ||
207 | * @return header id to list of data block hash | ||
208 | */ | ||
209 | static QuaExtraFieldHash parseExtraField(const QByteArray &extraField); | ||
210 | /// Extracts extended time from the extra field | ||
211 | /** | ||
212 | * Utility function used by various getExt*Time() functions, but can be used directly | ||
213 | * if the extra field is obtained elsewhere (from a third party library, for example). | ||
214 | * | ||
215 | * @param extra the extra field for a file | ||
216 | * @param flag 1 - modification time, 2 - access time, 4 - creation time | ||
217 | * @return the extracted time or null QDateTime if not present | ||
218 | * @sa getExtModTime() | ||
219 | * @sa QuaZipFile::getExtModTime() | ||
220 | * @sa QuaZipFile::getExtAcTime() | ||
221 | * @sa QuaZipFile::getExtCrTime() | ||
222 | */ | ||
223 | static QDateTime getExtTime(const QByteArray &extra, int flag); | ||
224 | }; | ||
225 | |||
226 | #endif | ||