summaryrefslogtreecommitdiff
path: root/utils/rbutilqt/quazip/quazipnewinfo.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/rbutilqt/quazip/quazipnewinfo.h')
-rw-r--r--utils/rbutilqt/quazip/quazipnewinfo.h208
1 files changed, 208 insertions, 0 deletions
diff --git a/utils/rbutilqt/quazip/quazipnewinfo.h b/utils/rbutilqt/quazip/quazipnewinfo.h
new file mode 100644
index 0000000000..43a1e6fd08
--- /dev/null
+++ b/utils/rbutilqt/quazip/quazipnewinfo.h
@@ -0,0 +1,208 @@
1#ifndef QUA_ZIPNEWINFO_H
2#define QUA_ZIPNEWINFO_H
3
4/*
5Copyright (C) 2005-2014 Sergey A. Tachenov
6
7This file is part of QuaZIP.
8
9QuaZIP is free software: you can redistribute it and/or modify
10it under the terms of the GNU Lesser General Public License as published by
11the Free Software Foundation, either version 2.1 of the License, or
12(at your option) any later version.
13
14QuaZIP is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License
20along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
21
22See COPYING file for the full LGPL text.
23
24Original ZIP package is copyrighted by Gilles Vollant, see
25quazip/(un)zip.h files for details, basically it's zlib license.
26 **/
27
28#include <QtCore/QDateTime>
29#include <QtCore/QFile>
30#include <QtCore/QString>
31
32#include "quazip_global.h"
33
34#include "quazipfileinfo.h"
35
36/// Information about a file to be created.
37/** This structure holds information about a file to be created inside
38 * ZIP archive. At least name should be set to something correct before
39 * passing this structure to
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.
49 **/
50struct QUAZIP_EXPORT QuaZipNewInfo {
51 /// File name.
52 /** This field holds file name inside archive, including path relative
53 * to archive root.
54 **/
55 QString name;
56 /// File timestamp.
57 /** This is the last file modification date and time. Will be stored
58 * in the archive central directory. It is a good practice to set it
59 * to the source file timestamp instead of archive creating time. Use
60 * setFileDateTime() or QuaZipNewInfo(const QString&, const QString&).
61 **/
62 QDateTime dateTime;
63 /// File internal attributes.
64 quint16 internalAttr;
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 */
71 quint32 externalAttr;
72 /// File comment.
73 /** Will be encoded in UTF-8 encoding.
74 **/
75 QString comment;
76 /// File local extra field.
77 QByteArray extraLocal;
78 /// File global extra field.
79 QByteArray extraGlobal;
80 /// Uncompressed file size.
81 /** This is only needed if you are using raw file zipping mode, i. e.
82 * adding precompressed file in the zip archive.
83 **/
84 ulong uncompressedSize;
85 /// Constructs QuaZipNewInfo instance.
86 /** Initializes name with \a name, dateTime with current date and
87 * time. Attributes are initialized with zeros, comment and extra
88 * field with null values.
89 **/
90 QuaZipNewInfo(const QString& name);
91 /// Constructs QuaZipNewInfo instance.
92 /** Initializes name with \a name. Timestamp and permissions are taken
93 * from the specified file. If the \a file does not exists or its timestamp
94 * is inaccessible (e. g. you do not have read permission for the
95 * directory file in), uses current time and zero permissions. Other attributes are
96 * initialized with zeros, comment and extra field with null values.
97 *
98 * \sa setFileDateTime()
99 **/
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);
117 /// Sets the file timestamp from the existing file.
118 /** Use this function to set the file timestamp from the existing
119 * file. Use it like this:
120 * \code
121 * QuaZipFile zipFile(&zip);
122 * QFile file("file-to-add");
123 * file.open(QIODevice::ReadOnly);
124 * QuaZipNewInfo info("file-name-in-archive");
125 * info.setFileDateTime("file-to-add"); // take the timestamp from file
126 * zipFile.open(QIODevice::WriteOnly, info);
127 * \endcode
128 *
129 * This function does not change dateTime if some error occured (e. g.
130 * file is inaccessible).
131 **/
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
152 * QFileInfo::birthTime() (>=Qt5.10) or QFileInfo::created(), are written to
153 * the NTFS extra field record.
154 *
155 * The NTFS record is written to
156 * both the local and the global extra fields, updating the existing record
157 * if there is one, or creating a new one and appending it to the end
158 * of each extra field.
159 *
160 * The microseconds will be zero, as they aren't reported by QFileInfo.
161 * @param fileName
162 */
163 void setFileNTFSTimes(const QString &fileName);
164 /// Sets the NTFS modification time.
165 /**
166 * The time is written into the NTFS record in
167 * both the local and the global extra fields, updating the existing record
168 * if there is one, or creating a new one and appending it to the end
169 * of each extra field. When updating an existing record, all other fields
170 * are left intact.
171 * @param mTime The new modification time.
172 * @param fineTicks The fractional part of milliseconds, in 100-nanosecond
173 * ticks (i. e. 9999 ticks = 999.9 microsecond). Values greater than
174 * 9999 will add milliseconds or even seconds, but this can be
175 * confusing and therefore is discouraged.
176 */
177 void setFileNTFSmTime(const QDateTime &mTime, int fineTicks = 0);
178 /// Sets the NTFS access time.
179 /**
180 * The time is written into the NTFS record in
181 * both the local and the global extra fields, updating the existing record
182 * if there is one, or creating a new one and appending it to the end
183 * of each extra field. When updating an existing record, all other fields
184 * are left intact.
185 * @param aTime The new access time.
186 * @param fineTicks The fractional part of milliseconds, in 100-nanosecond
187 * ticks (i. e. 9999 ticks = 999.9 microsecond). Values greater than
188 * 9999 will add milliseconds or even seconds, but this can be
189 * confusing and therefore is discouraged.
190 */
191 void setFileNTFSaTime(const QDateTime &aTime, int fineTicks = 0);
192 /// Sets the NTFS creation time.
193 /**
194 * The time is written into the NTFS record in
195 * both the local and the global extra fields, updating the existing record
196 * if there is one, or creating a new one and appending it to the end
197 * of each extra field. When updating an existing record, all other fields
198 * are left intact.
199 * @param cTime The new creation time.
200 * @param fineTicks The fractional part of milliseconds, in 100-nanosecond
201 * ticks (i. e. 9999 ticks = 999.9 microsecond). Values greater than
202 * 9999 will add milliseconds or even seconds, but this can be
203 * confusing and therefore is discouraged.
204 */
205 void setFileNTFScTime(const QDateTime &cTime, int fineTicks = 0);
206};
207
208#endif