23#define ZDEBUG if (0) qDebug
41 data[1] = (
i>>8) & 0xff;
42 data[2] = (
i>>16) & 0xff;
43 data[3] = (
i>>24) & 0xff;
49 data[1] = (
i>>8) & 0xff;
74 dest[0] =
time & 0xff;
83 dest[3] = char(
date >> 8);
98 stream.avail_in = (uInt)sourceLen;
99 if ((uLong)
stream.avail_in != sourceLen)
103 stream.avail_out = (uInt)*destLen;
104 if ((uLong)
stream.avail_out != *destLen)
107 stream.zalloc = (alloc_func)
nullptr;
108 stream.zfree = (free_func)
nullptr;
110 err = inflateInit2(&
stream, -MAX_WBITS);
115 if (err != Z_STREAM_END) {
117 if (err == Z_NEED_DICT || (err == Z_BUF_ERROR &&
stream.avail_in == 0))
121 *destLen =
stream.total_out;
123 err = inflateEnd(&
stream);
133 stream.avail_in = (uInt)sourceLen;
135 stream.avail_out = (uInt)*destLen;
136 if ((uLong)
stream.avail_out != *destLen)
return Z_BUF_ERROR;
138 stream.zalloc = (alloc_func)
nullptr;
139 stream.zfree = (free_func)
nullptr;
140 stream.opaque = (voidpf)
nullptr;
142 err = deflateInit2(&
stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY);
143 if (err != Z_OK)
return err;
146 if (err != Z_STREAM_END) {
148 return err == Z_OK ? Z_BUF_ERROR : err;
150 *destLen =
stream.total_out;
152 err = deflateEnd(&
stream);
190 QFile::Permissions
ret;
240 uDate = (
quint64)(dosDate >> 16);
241 uint tm_mday = (uDate & 0x1f);
242 uint tm_mon = ((uDate & 0x1E0) >> 5);
243 uint tm_year = (((uDate & 0x0FE00) >> 9) + 1980);
244 uint tm_hour = ((dosDate & 0xF800) >> 11);
245 uint tm_min = ((dosDate & 0x7E0) >> 5);
246 uint tm_sec = ((dosDate & 0x1f) << 1);
420 fileInfo.
isDir =
true;
435 fileInfo.
isDir =
true;
449 qWarning(
"QZip: Zip entry format at %d is not supported.",
index);
455 const bool inUtf8 = (general_purpose_bits &
Utf8Names) != 0;
465 filePathRef = filePathRef.
mid(1);
516 copyUInt(
h.uncompressed_size,
ch.uncompressed_size);
548 int num_dir_entries = 0;
552 if (pos < 0 || i > 65535) {
553 qWarning(
"QZip: EndOfDirectory not found");
559 if (
readUInt(eod.signature) == 0x06054b50)
569 if (comment_length !=
i)
570 qWarning(
"QZip: failed to parse zip file.");
575 for (
i = 0;
i < num_dir_entries; ++
i) {
579 qWarning(
"QZip: Failed to read complete header, index may be incomplete");
583 qWarning(
"QZip: invalid header signature, index may be incomplete");
590 qWarning(
"QZip: Failed to read filename from zip index, index may be incomplete");
596 qWarning(
"QZip: Failed to read extra field in zip file, skipping file, index may be incomplete");
602 qWarning(
"QZip: Failed to read read file comment, index may be incomplete");
614 static const char *
const entryTypes[] = {
660 qWarning(
"QZip: Z_MEM_ERROR: Not enough memory to compress file, skipping");
667 }
while (
res == Z_BUF_ERROR);
671 uint crc_32 = ::crc32(0,
nullptr, 0);
679 const bool inUtf8 = (general_purpose_bits &
Utf8Names) != 0;
682 qWarning(
"QZip: Filename is too long, chopping it to 65535 bytes");
686 qWarning(
"QZip: File comment is too long, chopping it to 65535 bytes");
788 auto f = std::make_unique<QFile>(archive);
865 files.reserve(numFileHeaders);
866 for (
int i = 0;
i < numFileHeaders; ++
i)
891 if (
index >= 0 && index < d->fileHeaders.size())
914 qWarning(
"QZip: .ZIP specification version %d implementationis needed to extract the data.", version_needed);
933 if ((general_purpose_bits &
Encrypted) != 0) {
934 qWarning(
"QZip: Unsupported encryption method is needed to extract the data.");
958 if ((
int)
len != baunzip.
size())
962 qWarning(
"QZip: Z_MEM_ERROR: Not enough memory");
968 qWarning(
"QZip: Z_DATA_ERROR: Input data is corrupted");
971 }
while (
res == Z_BUF_ERROR);
975 qWarning(
"QZip: Unsupported compression method %d is needed to extract the data.", compression_method);
986 QDir baseDir(destinationDir);
990 bool foundDirs =
false;
991 bool hasDirs =
false;
1010 if (hasDirs && !foundDirs) {
1013 if (!baseDir.
mkpath(dirPath))
1105 auto f = std::make_unique<QFile>(
fileName);
1273 bool opened =
false;
1294 if (!
name.endsWith(u
'/'))
IOBluetoothDevice * device
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
void truncate(qsizetype pos)
Truncates the byte array at index position pos.
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
\inmodule QtCore\reentrant
static QDateTime currentDateTime()
This is an overloaded member function, provided for convenience. It differs from the above function o...
QTime time() const
Returns the time part of the datetime.
bool isValid() const
Returns true if this datetime represents a definite moment, otherwise false.
QDate date() const
Returns the date part of the datetime.
\inmodule QtCore \reentrant
int month() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
int day() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
int year() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString fromNativeSeparators(const QString &pathName)
static QDir root()
Returns the root directory.
static QChar separator()
Returns the native directory separator: "/" under Unix and "\\" under Windows.
bool mkpath(const QString &dirPath) const
Creates the directory path dirPath.
FileError
This enum describes the errors that may be returned by the error() function.
\inmodule QtCore \reentrant
bool isSymLink() const
Returns true if this object points to a symbolic link, shortcut, or alias; otherwise returns false.
bool isFile() const
Returns true if this object points to a file or to a symbolic link to a file.
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory.
QString absolutePath() const
Returns a file's path absolute path.
QString filePath() const
Returns the file name, including the path (which may be absolute or relative).
QFile::Permissions permissions() const
Returns the complete OR-ed together combination of QFile::Permissions for the file.
bool setPermissions(Permissions permissionSpec) override
Sets the permissions for the file to the permissions specified.
bool link(const QString &newName)
Creates a link named linkName that points to the file currently specified by fileName().
static QByteArray encodeName(const QString &fileName)
Converts fileName to an 8-bit encoding that you can use in native APIs.
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
\inmodule QtCore \reentrant
virtual bool open(QIODeviceBase::OpenMode mode)
Opens the device and sets its OpenMode to mode.
virtual qint64 size() const
For open random-access devices, this function returns the size of the device.
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from.
bool isOpen() const
Returns true if the device is open; otherwise returns false.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
bool isReadable() const
Returns true if data can be read from the device; otherwise returns false.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
QIODeviceBase::OpenMode openMode() const
Returns the mode in which the device has been opened; i.e.
bool isWritable() const
Returns true if data can be written to the device; otherwise returns false.
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success,...
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
void append(parameter_type t)
bool startsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
constexpr void chop(qsizetype n) noexcept
Truncates this string view by length characters.
bool endsWith(QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QString toString() const
Returns a deep copy of this string view's data as a QString.
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
void truncate(qsizetype pos)
Truncates the string at the given position index.
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype size() const
Returns the number of characters in this string.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QChar * data()
Returns a pointer to the data stored in the QString.
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
\inmodule QtCore \reentrant
int hour() const
Returns the hour part (0 to 23) of the time.
int minute() const
Returns the minute part (0 to 59) of the time.
int second() const
Returns the second part (0 to 59) of the time.
QZipReader::FileInfo fillFileInfo(int index) const
QZipPrivate(QIODevice *device, bool ownDev)
QList< FileHeader > fileHeaders
QZipReader::Status status
QZipReaderPrivate(QIODevice *device, bool ownDev)
\variable FileInfo::filePath The full filepath inside the archive.
FileInfo entryInfoAt(int index) const
Returns a FileInfo of an entry in the zipfile.
QList< FileInfo > fileInfoList() const
Returns the list of files the archive contains.
void close()
Close the zip file.
QIODevice * device() const
Returns device used for reading zip archive.
bool exists() const
Returns true if the file exists; otherwise returns false.
QZipReader(const QString &fileName, QIODevice::OpenMode mode=QIODevice::ReadOnly)
Create a new zip archive that operates on the fileName.
bool isReadable() const
Returns true if the user can read the file; otherwise returns false.
Status status() const
Returns a status code indicating the first error that was met by QZipReader, or QZipReader::NoError i...
Status
The following status values are possible:
QByteArray fileData(const QString &fileName) const
Fetch the file contents from the zip archive and return the uncompressed bytes.
bool extractAll(const QString &destinationDir) const
Extracts the full contents of the zip file into destinationDir on the local filesystem.
int count() const
Return the number of items in the zip archive.
void addEntry(EntryType type, const QString &fileName, const QByteArray &contents)
QFile::Permissions permissions
QZipWriterPrivate(QIODevice *device, bool ownDev)
QZipWriter::Status status
QZipWriter::CompressionPolicy compressionPolicy
the QZipWriter class provides a way to create a new zip archive.
void addDirectory(const QString &dirName)
Create a new directory in the archive with the specified dirName and the permissions;.
QIODevice * device() const
Returns device used for writing zip archive.
void setCreationPermissions(QFile::Permissions permissions)
Sets the permissions that will be used for newly added files.
void addFile(const QString &fileName, const QByteArray &data)
Add a file to the archive with data as the file contents.
bool isWritable() const
Returns true if the user can write to the archive; otherwise returns false.
QZipWriter(const QString &fileName, QIODevice::OpenMode mode=(QIODevice::WriteOnly|QIODevice::Truncate))
Create a new zip archive that operates on the archive filename.
void close()
Closes the zip file.
QFile::Permissions creationPermissions() const
Returns the currently set creation permissions.
void setCompressionPolicy(CompressionPolicy policy)
Sets the policy for compressing newly added files to the new policy.
Status status() const
Returns a status code indicating the first error that was met by QZipWriter, or QZipWriter::NoError i...
Status
The following status values are possible:
CompressionPolicy
\value AlwaysCompress A file that is added is compressed.
bool exists() const
Returns true if the file exists; otherwise returns false.
CompressionPolicy compressionPolicy() const
Returns the currently set compression policy.
void addSymLink(const QString &fileName, const QString &destination)
Create a new symbolic link in the archive with the specified dirName and the permissions; A symbolic ...
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char * destination
DBusConnection const char DBusError * error
static QString header(const QString &name)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLsizei GLchar * source
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
unsigned long long quint64
ReturnedValue read(const char *data)
static QFile::Permissions modeToPermissions(quint32 mode)
static void copyUShort(uchar *dest, const uchar *src)
static QT_BEGIN_NAMESPACE uint readUInt(const uchar *data)
static void copyUInt(uchar *dest, const uchar *src)
@ CompressionMethodReduced1
@ CompressionMethodReduced4
@ CompressionMethodReduced3
@ CompressionMethodDeflated
@ CompressionMethodPKImploding
@ CompressionMethodShrunk
@ CompressionMethodReduced2
@ CompressionMethodStored
@ CompressionMethodReservedTokenizing
@ CompressionMethodDeflated64
@ CompressionMethodWavPack
@ CompressionMethodImploded
static void writeUInt(uchar *data, uint i)
static QDateTime readMSDosDate(const uchar *src)
static void writeMSDosDate(uchar *dest, const QDateTime &dt)
static LocalFileHeader toLocalHeader(const CentralFileHeader &ch)
static quint32 permissionsToMode(QFile::Permissions perms)
static void writeUShort(uchar *data, ushort i)
@ CentralDirectoryEncrypted
static int inflate(Bytef *dest, ulong *destLen, const Bytef *source, ulong sourceLen)
static int deflate(Bytef *dest, ulong *destLen, const Bytef *source, ulong sourceLen)
static ushort readUShort(const uchar *data)
QFileInfo fi("c:/temp/foo")
[newstuff]
uchar uncompressed_size[4]
uchar start_of_directory_disk[2]
uchar dir_start_offset[4]
uchar num_dir_entries_this_disk[2]
QFile::Permissions permissions