diff options
Diffstat (limited to 'rbutil/rbutilqt/quazip/quazipnewinfo.h')
-rw-r--r-- | rbutil/rbutilqt/quazip/quazipnewinfo.h | 152 |
1 files changed, 125 insertions, 27 deletions
diff --git a/rbutil/rbutilqt/quazip/quazipnewinfo.h b/rbutil/rbutilqt/quazip/quazipnewinfo.h index 93ff1a2fc0..bfd498682f 100644 --- a/rbutil/rbutilqt/quazip/quazipnewinfo.h +++ b/rbutil/rbutilqt/quazip/quazipnewinfo.h | |||
@@ -2,47 +2,52 @@ | |||
2 | #define QUA_ZIPNEWINFO_H | 2 | #define QUA_ZIPNEWINFO_H |
3 | 3 | ||
4 | /* | 4 | /* |
5 | -- A kind of "standard" GPL license statement -- | 5 | Copyright (C) 2005-2014 Sergey A. Tachenov |
6 | QuaZIP - a Qt/C++ wrapper for the ZIP/UNZIP package | ||
7 | Copyright (C) 2005-2007 Sergey A. Tachenov | ||
8 | 6 | ||
9 | This program is free software; you can redistribute it and/or modify it | 7 | This file is part of QuaZIP. |
10 | under the terms of the GNU General Public License as published by the | ||
11 | Free Software Foundation; either version 2 of the License, or (at your | ||
12 | option) any later version. | ||
13 | 8 | ||
14 | This program is distributed in the hope that it will be useful, but | 9 | QuaZIP is free software: you can redistribute it and/or modify |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | it under the terms of the GNU Lesser General Public License as published by |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 11 | the Free Software Foundation, either version 2.1 of the License, or |
17 | Public License for more details. | 12 | (at your option) any later version. |
18 | 13 | ||
19 | You should have received a copy of the GNU General Public License along | 14 | QuaZIP is distributed in the hope that it will be useful, |
20 | with this program; if not, write to the Free Software Foundation, Inc., | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | GNU Lesser General Public License for more details. | ||
22 | 18 | ||
23 | -- A kind of "standard" GPL license statement ends here -- | 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/>. | ||
24 | 21 | ||
25 | See COPYING file for GPL. | 22 | See COPYING file for the full LGPL text. |
26 | 23 | ||
27 | You are also permitted to use QuaZIP under the terms of LGPL (see | 24 | Original ZIP package is copyrighted by Gilles Vollant, see |
28 | COPYING.LGPL). You are free to choose either license, but please note | 25 | quazip/(un)zip.h files for details, basically it's zlib license. |
29 | that QuaZIP makes use of Qt, which is not licensed under LGPL. So if | ||
30 | you are using Open Source edition of Qt, you therefore MUST use GPL for | ||
31 | your code based on QuaZIP, since it would be also based on Qt in this | ||
32 | case. If you are Qt commercial license owner, then you are free to use | ||
33 | QuaZIP as long as you respect either GPL or LGPL for QuaZIP code. | ||
34 | **/ | 26 | **/ |
35 | 27 | ||
36 | #include <QDateTime> | 28 | #include <QDateTime> |
29 | #include <QFile> | ||
37 | #include <QString> | 30 | #include <QString> |
38 | 31 | ||
32 | #include "quazip_global.h" | ||
33 | |||
34 | #include "quazipfileinfo.h" | ||
35 | |||
39 | /// Information about a file to be created. | 36 | /// Information about a file to be created. |
40 | /** This structure holds information about a file to be created inside | 37 | /** This structure holds information about a file to be created inside |
41 | * ZIP archive. At least name should be set to something correct before | 38 | * ZIP archive. At least name should be set to something correct before |
42 | * passing this structure to | 39 | * passing this structure to |
43 | * QuaZipFile::open(OpenMode,const QuaZipNewInfo&,int,int,bool). | 40 | * QuaZipFile::open(OpenMode,const QuaZipNewInfo&,int,int,bool). |
41 | * | ||
42 | * Zip64 support of this structure is slightly limited: in the raw mode (when | ||
43 | * a pre-compressed file is written into a ZIP file as-is), it is necessary | ||
44 | * to specify the uncompressed file size and the appropriate field is 32 bit. | ||
45 | * Since the raw mode is used extremely rare, there is no real need to have | ||
46 | * a separate QuaZipNewInfo64 structure like QuaZipFileInfo64. It may be added | ||
47 | * in the future though, if there is a demand for the raw mode with zip64 | ||
48 | * archives. | ||
44 | **/ | 49 | **/ |
45 | struct QuaZipNewInfo { | 50 | struct QUAZIP_EXPORT QuaZipNewInfo { |
46 | /// File name. | 51 | /// File name. |
47 | /** This field holds file name inside archive, including path relative | 52 | /** This field holds file name inside archive, including path relative |
48 | * to archive root. | 53 | * to archive root. |
@@ -58,6 +63,11 @@ struct QuaZipNewInfo { | |||
58 | /// File internal attributes. | 63 | /// File internal attributes. |
59 | quint16 internalAttr; | 64 | quint16 internalAttr; |
60 | /// File external attributes. | 65 | /// File external attributes. |
66 | /** | ||
67 | The highest 16 bits contain Unix file permissions and type (dir or | ||
68 | file). The constructor QuaZipNewInfo(const QString&, const QString&) | ||
69 | takes permissions from the provided file. | ||
70 | */ | ||
61 | quint32 externalAttr; | 71 | quint32 externalAttr; |
62 | /// File comment. | 72 | /// File comment. |
63 | /** Will be encoded using QuaZip::getCommentCodec(). | 73 | /** Will be encoded using QuaZip::getCommentCodec(). |
@@ -79,15 +89,31 @@ struct QuaZipNewInfo { | |||
79 | **/ | 89 | **/ |
80 | QuaZipNewInfo(const QString& name); | 90 | QuaZipNewInfo(const QString& name); |
81 | /// Constructs QuaZipNewInfo instance. | 91 | /// Constructs QuaZipNewInfo instance. |
82 | /** Initializes name with \a name and dateTime with timestamp of the | 92 | /** Initializes name with \a name. Timestamp and permissions are taken |
83 | * file named \a file. If the \a file does not exists or its timestamp | 93 | * from the specified file. If the \a file does not exists or its timestamp |
84 | * is inaccessible (e. g. you do not have read permission for the | 94 | * is inaccessible (e. g. you do not have read permission for the |
85 | * directory file in), uses current date and time. Attributes are | 95 | * directory file in), uses current time and zero permissions. Other attributes are |
86 | * initialized with zeros, comment and extra field with null values. | 96 | * initialized with zeros, comment and extra field with null values. |
87 | * | 97 | * |
88 | * \sa setFileDateTime() | 98 | * \sa setFileDateTime() |
89 | **/ | 99 | **/ |
90 | QuaZipNewInfo(const QString& name, const QString& file); | 100 | QuaZipNewInfo(const QString& name, const QString& file); |
101 | /// Initializes the new instance from existing file info. | ||
102 | /** Mainly used when copying files between archives. | ||
103 | * | ||
104 | * Both extra fields are initialized to existing.extra. | ||
105 | * @brief QuaZipNewInfo | ||
106 | * @param existing | ||
107 | */ | ||
108 | QuaZipNewInfo(const QuaZipFileInfo &existing); | ||
109 | /// Initializes the new instance from existing file info. | ||
110 | /** Mainly used when copying files between archives. | ||
111 | * | ||
112 | * Both extra fields are initialized to existing.extra. | ||
113 | * @brief QuaZipNewInfo | ||
114 | * @param existing | ||
115 | */ | ||
116 | QuaZipNewInfo(const QuaZipFileInfo64 &existing); | ||
91 | /// Sets the file timestamp from the existing file. | 117 | /// Sets the file timestamp from the existing file. |
92 | /** Use this function to set the file timestamp from the existing | 118 | /** Use this function to set the file timestamp from the existing |
93 | * file. Use it like this: | 119 | * file. Use it like this: |
@@ -104,6 +130,78 @@ struct QuaZipNewInfo { | |||
104 | * file is inaccessible). | 130 | * file is inaccessible). |
105 | **/ | 131 | **/ |
106 | void setFileDateTime(const QString& file); | 132 | void setFileDateTime(const QString& file); |
133 | /// Sets the file permissions from the existing file. | ||
134 | /** | ||
135 | Takes permissions from the file and sets the high 16 bits of | ||
136 | external attributes. Uses QFileInfo to get permissions on all | ||
137 | platforms. | ||
138 | */ | ||
139 | void setFilePermissions(const QString &file); | ||
140 | /// Sets the file permissions. | ||
141 | /** | ||
142 | Modifies the highest 16 bits of external attributes. The type part | ||
143 | is set to dir if the name ends with a slash, and to regular file | ||
144 | otherwise. | ||
145 | */ | ||
146 | void setPermissions(QFile::Permissions permissions); | ||
147 | /// Sets the NTFS times from an existing file. | ||
148 | /** | ||
149 | * If the file doesn't exist, a warning is printed to the stderr and nothing | ||
150 | * is done. Otherwise, all three times, as reported by | ||
151 | * QFileInfo::lastModified(), QFileInfo::lastRead() and QFileInfo::created(), | ||
152 | * are written to the NTFS extra field record. | ||
153 | * | ||
154 | * The NTFS record is written to | ||
155 | * both the local and the global extra fields, updating the existing record | ||
156 | * if there is one, or creating a new one and appending it to the end | ||
157 | * of each extra field. | ||
158 | * | ||
159 | * The microseconds will be zero, as they aren't reported by QFileInfo. | ||
160 | * @param fileName | ||
161 | */ | ||
162 | void setFileNTFSTimes(const QString &fileName); | ||
163 | /// Sets the NTFS modification time. | ||
164 | /** | ||
165 | * The time is written into the NTFS record in | ||
166 | * both the local and the global extra fields, updating the existing record | ||
167 | * if there is one, or creating a new one and appending it to the end | ||
168 | * of each extra field. When updating an existing record, all other fields | ||
169 | * are left intact. | ||
170 | * @param mTime The new modification time. | ||
171 | * @param fineTicks The fractional part of milliseconds, in 100-nanosecond | ||
172 | * ticks (i. e. 9999 ticks = 999.9 microsecond). Values greater than | ||
173 | * 9999 will add milliseconds or even seconds, but this can be | ||
174 | * confusing and therefore is discouraged. | ||
175 | */ | ||
176 | void setFileNTFSmTime(const QDateTime &mTime, int fineTicks = 0); | ||
177 | /// Sets the NTFS access time. | ||
178 | /** | ||
179 | * The time is written into the NTFS record in | ||
180 | * both the local and the global extra fields, updating the existing record | ||
181 | * if there is one, or creating a new one and appending it to the end | ||
182 | * of each extra field. When updating an existing record, all other fields | ||
183 | * are left intact. | ||
184 | * @param aTime The new access time. | ||
185 | * @param fineTicks The fractional part of milliseconds, in 100-nanosecond | ||
186 | * ticks (i. e. 9999 ticks = 999.9 microsecond). Values greater than | ||
187 | * 9999 will add milliseconds or even seconds, but this can be | ||
188 | * confusing and therefore is discouraged. | ||
189 | */ | ||
190 | void setFileNTFSaTime(const QDateTime &aTime, int fineTicks = 0); | ||
191 | /// Sets the NTFS creation time. | ||
192 | /** | ||
193 | * The time is written into the NTFS record in | ||
194 | * both the local and the global extra fields, updating the existing record | ||
195 | * if there is one, or creating a new one and appending it to the end | ||
196 | * of each extra field. When updating an existing record, all other fields | ||
197 | * are left intact. | ||
198 | * @param cTime The new creation time. | ||
199 | * @param fineTicks The fractional part of milliseconds, in 100-nanosecond | ||
200 | * ticks (i. e. 9999 ticks = 999.9 microsecond). Values greater than | ||
201 | * 9999 will add milliseconds or even seconds, but this can be | ||
202 | * confusing and therefore is discouraged. | ||
203 | */ | ||
204 | void setFileNTFScTime(const QDateTime &cTime, int fineTicks = 0); | ||
107 | }; | 205 | }; |
108 | 206 | ||
109 | #endif | 207 | #endif |