source: s10k/CommonLibs/quazip-0.7.2/quazip/quazipnewinfo.h@ 1168

Last change on this file since 1168 was 1096, checked in by s10k, 7 years ago

Added zlib, quazip, basicxmlsyntaxhighlighter, conditionalsemaphore and linenumberdisplay libraries. zlib and quazip are pre-compiled, but you can compile them yourself, just delete the dll files (or equivalent binary files to your OS)

File size: 8.4 KB
RevLine 
[1096]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 <QDateTime>
29#include <QFile>
30#include <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 using QuaZip::getCommentCodec().
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 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);
205};
206
207#endif
Note: See TracBrowser for help on using the repository browser.