32 QFile::Permissions perm,
34 bool isSymLink =
false) {
35 quint32 uPerm = isDir ? 0040000 : 0100000;
45 if ((perm & QFile::ReadOwner) != 0) uPerm |= 0400;
46 if ((perm & QFile::WriteOwner) != 0) uPerm |= 0200;
47 if ((perm & QFile::ExeOwner) != 0) uPerm |= 0100;
48 if ((perm & QFile::ReadGroup) != 0) uPerm |= 0040;
49 if ((perm & QFile::WriteGroup) != 0) uPerm |= 0020;
50 if ((perm & QFile::ExeGroup) != 0) uPerm |= 0010;
51 if ((perm & QFile::ReadOther) != 0) uPerm |= 0004;
52 if ((perm & QFile::WriteOther) != 0) uPerm |= 0002;
53 if ((perm & QFile::ExeOther) != 0) uPerm |= 0001;
57 template <
typename FileInfo>
59 self.name = existing.name;
60 self.dateTime = existing.dateTime;
61 self.internalAttr = existing.internalAttr;
62 self.externalAttr = existing.externalAttr;
63 self.comment = existing.comment;
64 self.extraLocal = existing.extra;
65 self.extraGlobal = existing.extra;
66 self.uncompressedSize = existing.uncompressedSize;
79 dateTime(QDateTime::currentDateTime()),
82 uncompressedSize(0) {}
85 :
name(
name), internalAttr(0), externalAttr(0), uncompressedSize(0) {
87 QDateTime lm = info.lastModified();
89 dateTime = QDateTime::currentDateTime();
99 QDateTime lm = info.lastModified();
104 QFileInfo info = QFileInfo(file);
105 QFile::Permissions perm = info.permissions();
114 QFileInfo fi(fileName);
116 qWarning(
"QuaZipNewInfo::setFileNTFSTimes(): '%s' doesn't exist",
117 fileName.toUtf8().constData());
122 #if QT_DEPRECATED_SINCE(5, 10)
130 const QDateTime &time,
133 int ntfsPos = -1, timesPos = -1;
134 unsigned ntfsLength = 0, ntfsTimesLength = 0;
135 for (
int i = 0; i <= extra.size() - 4;) {
137 static_cast<unsigned>(
static_cast<unsigned char>(extra.at(i))) |
138 (
static_cast<unsigned>(
139 static_cast<unsigned char>(extra.at(i + 1)))
143 static_cast<unsigned>(
static_cast<unsigned char>(extra.at(i))) |
144 (
static_cast<unsigned>(
145 static_cast<unsigned char>(extra.at(i + 1)))
155 while (i <= extra.size() - 4) {
157 static_cast<unsigned>(
158 static_cast<unsigned char>(extra.at(i))) |
159 (
static_cast<unsigned>(
160 static_cast<unsigned char>(extra.at(i + 1)))
164 static_cast<unsigned>(
165 static_cast<unsigned char>(extra.at(i))) |
166 (
static_cast<unsigned>(
167 static_cast<unsigned char>(extra.at(i + 1)))
172 ntfsTimesLength = tagsize;
185 ntfsPos = extra.size();
187 extra.resize(extra.size() + 4 + ntfsLength);
191 extra[ntfsPos + 2] = 32;
192 extra[ntfsPos + 3] = 0;
194 memset(extra.data() + ntfsPos + 4, 0, 32);
195 timesPos = ntfsPos + 8;
198 extra[timesPos + 1] =
201 extra[timesPos + 2] = 24;
202 extra[timesPos + 3] = 0;
203 ntfsTimesLength = 24;
205 if (timesPos == -1) {
207 timesPos = ntfsPos + 4 + ntfsLength;
208 extra.resize(extra.size() + 28);
213 memmove(extra.data() + timesPos + 28, extra.data() + timesPos,
214 extra.size() - 28 - timesPos);
218 extra[timesPos + 1] =
221 extra[timesPos + 2] = 24;
222 extra[timesPos + 3] = 0;
224 memset(extra.data() + timesPos + 4, 0, 24);
225 ntfsTimesLength = 24;
227 if (ntfsTimesLength < 24) {
229 size_t timesEnd = timesPos + 4 + ntfsTimesLength;
230 extra.resize(extra.size() + (24 - ntfsTimesLength));
234 memmove(extra.data() + timesEnd + (24 - ntfsTimesLength),
235 extra.data() + timesEnd,
236 extra.size() - (24 - ntfsTimesLength) - timesEnd);
238 ntfsLength += (24 - ntfsTimesLength);
239 ntfsTimesLength = 24;
240 extra[ntfsPos + 2] =
static_cast<char>(ntfsLength);
241 extra[ntfsPos + 3] =
static_cast<char>(ntfsLength >> 8);
242 extra[timesPos + 2] =
static_cast<char>(ntfsTimesLength);
243 extra[timesPos + 3] =
static_cast<char>(ntfsTimesLength >> 8);
245 QDateTime base(QDate(1601, 1, 1), QTime(0, 0), Qt::UTC);
246 #if (QT_VERSION >= 0x040700)
247 quint64 ticks = base.msecsTo(time) * 10000 + fineTicks;
249 QDateTime utc = time.toUTC();
250 quint64 ticks = (
static_cast<qint64
>(base.date().daysTo(utc.date())) *
251 Q_INT64_C(86400000) +
252 static_cast<qint64
>(base.time().msecsTo(utc.time()))) *
256 extra[timesPos + 4 +
position] =
static_cast<char>(ticks);
257 extra[timesPos + 5 +
position] =
static_cast<char>(ticks >> 8);
258 extra[timesPos + 6 +
position] =
static_cast<char>(ticks >> 16);
259 extra[timesPos + 7 +
position] =
static_cast<char>(ticks >> 24);
260 extra[timesPos + 8 +
position] =
static_cast<char>(ticks >> 32);
261 extra[timesPos + 9 +
position] =
static_cast<char>(ticks >> 40);
262 extra[timesPos + 10 +
position] =
static_cast<char>(ticks >> 48);
263 extra[timesPos + 11 +
position] =
static_cast<char>(ticks >> 56);
__host__ __device__ float length(float2 v)
#define QUAZIP_EXTRA_NTFS_TIME_MAGIC
#define QUAZIP_EXTRA_NTFS_MAGIC
void QuaZipNewInfo_init(QuaZipNewInfo &self, const FileInfo &existing)
static void QuaZipNewInfo_setPermissions(QuaZipNewInfo *info, QFile::Permissions perm, bool isDir, bool isSymLink=false)
static void setNTFSTime(QByteArray &extra, const QDateTime &time, int position, int fineTicks)
Information about a file inside archive (with zip64 support).
Information about a file inside archive.
Information about a file to be created.
void setFilePermissions(const QString &file)
Sets the file permissions from the existing file.
void setFileNTFSaTime(const QDateTime &aTime, int fineTicks=0)
Sets the NTFS access time.
void setFileDateTime(const QString &file)
Sets the file timestamp from the existing file.
void setFileNTFSmTime(const QDateTime &mTime, int fineTicks=0)
Sets the NTFS modification time.
void setFileNTFScTime(const QDateTime &cTime, int fineTicks=0)
Sets the NTFS creation time.
QuaZipNewInfo(const QString &name)
Constructs QuaZipNewInfo instance.
void setFileNTFSTimes(const QString &fileName)
Sets the NTFS times from an existing file.
QByteArray extraLocal
File local extra field.
QByteArray extraGlobal
File global extra field.
QDateTime dateTime
File timestamp.
void setPermissions(QFile::Permissions permissions)
Sets the file permissions.
quint32 externalAttr
File external attributes.