| quazip.h | | quazip.h | |
| | | | |
| skipping to change at line 156 | | skipping to change at line 156 | |
| /// Opens ZIP file. | | /// Opens ZIP file. | |
| /** | | /** | |
| * Argument \a mode specifies open mode of the ZIP archive. See Mode | | * Argument \a mode specifies open mode of the ZIP archive. See Mode | |
| * for details. Note that there is zipOpen2() function in the | | * for details. Note that there is zipOpen2() function in the | |
| * ZIP/UNZIP API which accepts \a globalcomment argument, but it | | * ZIP/UNZIP API which accepts \a globalcomment argument, but it | |
| * does not use it anywhere, so this open() function does not have this | | * does not use it anywhere, so this open() function does not have this | |
| * argument. See setComment() if you need to set global comment. | | * argument. See setComment() if you need to set global comment. | |
| * | | * | |
| * If the ZIP file is accessed via explicitly set QIODevice, then | | * If the ZIP file is accessed via explicitly set QIODevice, then | |
| * this device is opened in the necessary mode. If the device was | | * this device is opened in the necessary mode. If the device was | |
|
| * already opened by some other means, then the behaviour is defined by | | * already opened by some other means, then QuaZIP checks if the | |
| * the device implementation, but generally it is not a very good | | * open mode is compatible to the mode needed for the requested operati | |
| * idea. For example, QFile will at least issue a warning. | | on. | |
| | | * If necessary, seeking is performed to position the device properly. | |
| * | | * | |
| * \return \c true if successful, \c false otherwise. | | * \return \c true if successful, \c false otherwise. | |
| * | | * | |
| * \note ZIP/UNZIP API open calls do not return error code - they | | * \note ZIP/UNZIP API open calls do not return error code - they | |
| * just return \c NULL indicating an error. But to make things | | * just return \c NULL indicating an error. But to make things | |
| * easier, quazip.h header defines additional error code \c | | * easier, quazip.h header defines additional error code \c | |
| * UNZ_ERROROPEN and getZipError() will return it if the open call | | * UNZ_ERROROPEN and getZipError() will return it if the open call | |
| * of the ZIP/UNZIP API returns \c NULL. | | * of the ZIP/UNZIP API returns \c NULL. | |
| * | | * | |
| * Argument \a ioApi specifies IO function set for ZIP/UNZIP | | * Argument \a ioApi specifies IO function set for ZIP/UNZIP | |
| | | | |
| skipping to change at line 189 | | skipping to change at line 189 | |
| * | | * | |
| * \note If the zip64 support is needed, the ioApi argument \em must be
NULL | | * \note If the zip64 support is needed, the ioApi argument \em must be
NULL | |
| * because due to the backwards compatibility issues it can be used to | | * because due to the backwards compatibility issues it can be used to | |
| * provide a 32-bit API only. | | * provide a 32-bit API only. | |
| * | | * | |
| * In short: just forget about the \a ioApi argument and you'll be | | * In short: just forget about the \a ioApi argument and you'll be | |
| * fine. | | * fine. | |
| **/ | | **/ | |
| bool open(Mode mode, zlib_filefunc_def *ioApi =NULL); | | bool open(Mode mode, zlib_filefunc_def *ioApi =NULL); | |
| /// Closes ZIP file. | | /// Closes ZIP file. | |
|
| /** Call getZipError() to determine if the close was successful. The | | /** Call getZipError() to determine if the close was successful. | |
| * underlying QIODevice is also closed, regardless of whether it was | | * | |
| * set explicitly or not. */ | | * If the file was opened by name, then the underlying QIODevice is clo | |
| | | sed | |
| | | * and deleted. | |
| | | * | |
| | | * If the underlying QIODevice was set explicitly using setIoDevice() o | |
| | | r | |
| | | * the appropriate constructor, then it is closed if the auto-close fla | |
| | | g | |
| | | * is set (which it is by default). Call setAutoClose() to clear the | |
| | | * auto-close flag if this behavior is undesirable. | |
| | | * | |
| | | * Since Qt 5.1, the QSaveFile was introduced. It breaks the QIODevice | |
| | | API | |
| | | * by making close() private and crashing the application if it is call | |
| | | ed | |
| | | * from the base class where it is public. It is an excellent example | |
| | | * of poor design that illustrates why you should never ever break | |
| | | * an is-a relationship between the base class and a subclass. QuaZIP | |
| | | * works around this bug by checking if the QIODevice is an instance | |
| | | * of QSaveFile, using qobject_cast<>, and if it is, calls | |
| | | * QSaveFile::commit() instead of close(). It is a really ugly hack, | |
| | | * but at least it makes your programs work instead of crashing. Note t | |
| | | hat | |
| | | * if the auto-close flag is cleared, then this is a non-issue, and | |
| | | * commit() isn't called. | |
| | | */ | |
| void close(); | | void close(); | |
| /// Sets the codec used to encode/decode file names inside archive. | | /// Sets the codec used to encode/decode file names inside archive. | |
| /** This is necessary to access files in the ZIP archive created | | /** This is necessary to access files in the ZIP archive created | |
| * under Windows with non-latin characters in file names. For | | * under Windows with non-latin characters in file names. For | |
| * example, file names with cyrillic letters will be in \c IBM866 | | * example, file names with cyrillic letters will be in \c IBM866 | |
| * encoding. | | * encoding. | |
| **/ | | **/ | |
| void setFileNameCodec(QTextCodec *fileNameCodec); | | void setFileNameCodec(QTextCodec *fileNameCodec); | |
| /// Sets the codec used to encode/decode file names inside archive. | | /// Sets the codec used to encode/decode file names inside archive. | |
| /** \overload | | /** \overload | |
| | | | |
| skipping to change at line 463 | | skipping to change at line 482 | |
| QList<QuaZipFileInfo64> getFileInfoList64() const; | | QList<QuaZipFileInfo64> getFileInfoList64() const; | |
| /// Enables the zip64 mode. | | /// Enables the zip64 mode. | |
| /** | | /** | |
| * @param zip64 If \c true, the zip64 mode is enabled, disabled otherwi
se. | | * @param zip64 If \c true, the zip64 mode is enabled, disabled otherwi
se. | |
| * | | * | |
| * Once this is enabled, all new files (until the mode is disabled agai
n) | | * Once this is enabled, all new files (until the mode is disabled agai
n) | |
| * will be created in the zip64 mode, thus enabling the ability to writ
e | | * will be created in the zip64 mode, thus enabling the ability to writ
e | |
| * files larger than 4 GB. By default, the zip64 mode is off due to | | * files larger than 4 GB. By default, the zip64 mode is off due to | |
| * compatibility reasons. | | * compatibility reasons. | |
| * | | * | |
|
| | | * Note that this does not affect the ability to read zip64 archives in | |
| | | any | |
| | | * way. | |
| | | * | |
| * \sa isZip64Enabled() | | * \sa isZip64Enabled() | |
| */ | | */ | |
| void setZip64Enabled(bool zip64); | | void setZip64Enabled(bool zip64); | |
| /// Returns whether the zip64 mode is enabled. | | /// Returns whether the zip64 mode is enabled. | |
| /** | | /** | |
| * @return \c true if and only if the zip64 mode is enabled. | | * @return \c true if and only if the zip64 mode is enabled. | |
| * | | * | |
| * \sa setZip64Enabled() | | * \sa setZip64Enabled() | |
| */ | | */ | |
| bool isZip64Enabled() const; | | bool isZip64Enabled() const; | |
|
| | | /// Returns the auto-close flag. | |
| | | /** | |
| | | @sa setAutoClose() | |
| | | */ | |
| | | bool isAutoClose() const; | |
| | | /// Sets or unsets the auto-close flag. | |
| | | /** | |
| | | By default, QuaZIP opens the underlying QIODevice when open() is call | |
| | | ed, | |
| | | and closes it when close() is called. In some cases, when the device | |
| | | is set explicitly using setIoDevice(), it may be desirable to | |
| | | leave the device open. If the auto-close flag is unset using this met | |
| | | hod, | |
| | | then the device isn't closed automatically if it was set explicitly. | |
| | | | |
| | | If it is needed to clear this flag, it is recommended to do so before | |
| | | opening the archive because otherwise QuaZIP may close the device | |
| | | during the open() call if an error is encountered after the device | |
| | | is opened. | |
| | | | |
| | | If the device was not set explicitly, but rather the setZipName() or | |
| | | the appropriate constructor was used to set the ZIP file name instead | |
| | | , | |
| | | then the auto-close flag has no effect, and the internal device | |
| | | is closed nevertheless because there is no other way to close it. | |
| | | | |
| | | @sa isAutoClose() | |
| | | @sa setIoDevice() | |
| | | */ | |
| | | void setAutoClose(bool autoClose) const; | |
| /// Sets the default file name codec to use. | | /// Sets the default file name codec to use. | |
| /** | | /** | |
| * The default codec is used by the constructors, so calling this funct
ion | | * The default codec is used by the constructors, so calling this funct
ion | |
| * won't affect the QuaZip instances already created at that moment. | | * won't affect the QuaZip instances already created at that moment. | |
| * | | * | |
| * The codec specified here can be overriden by calling setFileNameCode
c(). | | * The codec specified here can be overriden by calling setFileNameCode
c(). | |
| * If neither function is called, QTextCodec::codecForLocale() will be
used | | * If neither function is called, QTextCodec::codecForLocale() will be
used | |
| * to decode or encode file names. Use this function with caution if | | * to decode or encode file names. Use this function with caution if | |
| * the application uses other libraries that depend on QuaZIP. Those | | * the application uses other libraries that depend on QuaZIP. Those | |
| * libraries can either call this function by themselves, thus overridi
ng | | * libraries can either call this function by themselves, thus overridi
ng | |
| | | | |
End of changes. 4 change blocks. |
| 6 lines changed or deleted | | 66 lines changed or added | |
|
| quazipfileinfo.h | | quazipfileinfo.h | |
| | | | |
| skipping to change at line 89 | | skipping to change at line 89 | |
| QString name; | | QString name; | |
| /// Version created by. | | /// Version created by. | |
| quint16 versionCreated; | | quint16 versionCreated; | |
| /// Version needed to extract. | | /// Version needed to extract. | |
| quint16 versionNeeded; | | quint16 versionNeeded; | |
| /// General purpose flags. | | /// General purpose flags. | |
| quint16 flags; | | quint16 flags; | |
| /// Compression method. | | /// Compression method. | |
| quint16 method; | | quint16 method; | |
| /// Last modification date and time. | | /// Last modification date and time. | |
|
| | | /** | |
| | | * This is the time stored in the standard ZIP header. This format only a | |
| | | llows | |
| | | * to store time with 2-second precision, so the seconds will always be e | |
| | | ven | |
| | | * and the milliseconds will always be zero. If you need more precise | |
| | | * date and time, you can try to call the getNTFSmTime() function or | |
| | | * its siblings, provided that the archive itself contains these NTFS tim | |
| | | es. | |
| | | */ | |
| QDateTime dateTime; | | QDateTime dateTime; | |
| /// CRC. | | /// CRC. | |
| quint32 crc; | | quint32 crc; | |
| /// Compressed file size. | | /// Compressed file size. | |
| quint64 compressedSize; | | quint64 compressedSize; | |
| /// Uncompressed file size. | | /// Uncompressed file size. | |
| quint64 uncompressedSize; | | quint64 uncompressedSize; | |
| /// Disk number start. | | /// Disk number start. | |
| quint16 diskNumberStart; | | quint16 diskNumberStart; | |
| /// Internal file attributes. | | /// Internal file attributes. | |
| | | | |
| skipping to change at line 124 | | skipping to change at line 131 | |
| If any of the fields are greater than 0xFFFFFFFFu, they are set to | | If any of the fields are greater than 0xFFFFFFFFu, they are set to | |
| 0xFFFFFFFFu exactly, not just truncated. This function should be mainly
used | | 0xFFFFFFFFu exactly, not just truncated. This function should be mainly
used | |
| for compatibility with the old code expecting QuaZipFileInfo, in the ca
ses | | for compatibility with the old code expecting QuaZipFileInfo, in the ca
ses | |
| when it's impossible or otherwise unadvisable (due to ABI compatibility | | when it's impossible or otherwise unadvisable (due to ABI compatibility | |
| reasons, for example) to modify that old code to use QuaZipFileInfo64. | | reasons, for example) to modify that old code to use QuaZipFileInfo64. | |
| | | | |
| \return \c true if all fields converted correctly, \c false if an overf
low | | \return \c true if all fields converted correctly, \c false if an overf
low | |
| occured. | | occured. | |
| */ | | */ | |
| bool toQuaZipFileInfo(QuaZipFileInfo &info) const; | | bool toQuaZipFileInfo(QuaZipFileInfo &info) const; | |
|
| | | /// Returns the NTFS modification time | |
| | | /** | |
| | | * The getNTFS*Time() functions only work if there is an NTFS extra field | |
| | | * present. Otherwise, they all return invalid null timestamps. | |
| | | * @param fineTicks If not NULL, the fractional part of milliseconds retu | |
| | | rned | |
| | | * there, measured in 100-nanosecond ticks. Will be set | |
| | | to | |
| | | * zero if there is no NTFS extra field. | |
| | | * @sa dateTime | |
| | | * @sa getNTFSaTime() | |
| | | * @sa getNTFScTime() | |
| | | * @return The NTFS modification time, UTC | |
| | | */ | |
| | | QDateTime getNTFSmTime(int *fineTicks = NULL) const; | |
| | | /// Returns the NTFS access time | |
| | | /** | |
| | | * The getNTFS*Time() functions only work if there is an NTFS extra field | |
| | | * present. Otherwise, they all return invalid null timestamps. | |
| | | * @param fineTicks If not NULL, the fractional part of milliseconds retu | |
| | | rned | |
| | | * there, measured in 100-nanosecond ticks. Will be set | |
| | | to | |
| | | * zero if there is no NTFS extra field. | |
| | | * @sa dateTime | |
| | | * @sa getNTFSmTime() | |
| | | * @sa getNTFScTime() | |
| | | * @return The NTFS access time, UTC | |
| | | */ | |
| | | QDateTime getNTFSaTime(int *fineTicks = NULL) const; | |
| | | /// Returns the NTFS creation time | |
| | | /** | |
| | | * The getNTFS*Time() functions only work if there is an NTFS extra field | |
| | | * present. Otherwise, they all return invalid null timestamps. | |
| | | * @param fineTicks If not NULL, the fractional part of milliseconds retu | |
| | | rned | |
| | | * there, measured in 100-nanosecond ticks. Will be set | |
| | | to | |
| | | * zero if there is no NTFS extra field. | |
| | | * @sa dateTime | |
| | | * @sa getNTFSmTime() | |
| | | * @sa getNTFSaTime() | |
| | | * @return The NTFS creation time, UTC | |
| | | */ | |
| | | QDateTime getNTFScTime(int *fineTicks = NULL) const; | |
| }; | | }; | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 2 change blocks. |
| 0 lines changed or deleted | | 55 lines changed or added | |
|
| quazipnewinfo.h | | quazipnewinfo.h | |
| | | | |
| skipping to change at line 34 | | skipping to change at line 34 | |
| Original ZIP package is copyrighted by Gilles Vollant, see | | Original ZIP package is copyrighted by Gilles Vollant, see | |
| quazip/(un)zip.h files for details, basically it's zlib license. | | quazip/(un)zip.h files for details, basically it's zlib license. | |
| **/ | | **/ | |
| | | | |
| #include <QDateTime> | | #include <QDateTime> | |
| #include <QFile> | | #include <QFile> | |
| #include <QString> | | #include <QString> | |
| | | | |
| #include "quazip_global.h" | | #include "quazip_global.h" | |
| | | | |
|
| | | #include "quazipfileinfo.h" | |
| | | | |
| /// Information about a file to be created. | | /// Information about a file to be created. | |
| /** This structure holds information about a file to be created inside | | /** This structure holds information about a file to be created inside | |
| * ZIP archive. At least name should be set to something correct before | | * ZIP archive. At least name should be set to something correct before | |
| * passing this structure to | | * passing this structure to | |
| * QuaZipFile::open(OpenMode,const QuaZipNewInfo&,int,int,bool). | | * QuaZipFile::open(OpenMode,const QuaZipNewInfo&,int,int,bool). | |
| * | | * | |
| * Zip64 support of this structure is slightly limited: in the raw mode (wh
en | | * Zip64 support of this structure is slightly limited: in the raw mode (wh
en | |
| * a pre-compressed file is written into a ZIP file as-is), it is necessary | | * a pre-compressed file is written into a ZIP file as-is), it is necessary | |
| * to specify the uncompressed file size and the appropriate field is 32 bi
t. | | * to specify the uncompressed file size and the appropriate field is 32 bi
t. | |
| * Since the raw mode is used extremely rare, there is no real need to have | | * Since the raw mode is used extremely rare, there is no real need to have | |
| | | | |
| skipping to change at line 99 | | skipping to change at line 101 | |
| /// Constructs QuaZipNewInfo instance. | | /// Constructs QuaZipNewInfo instance. | |
| /** Initializes name with \a name. Timestamp and permissions are taken | | /** Initializes name with \a name. Timestamp and permissions are taken | |
| * from the specified file. If the \a file does not exists or its timesta
mp | | * from the specified file. If the \a file does not exists or its timesta
mp | |
| * is inaccessible (e. g. you do not have read permission for the | | * is inaccessible (e. g. you do not have read permission for the | |
| * directory file in), uses current time and zero permissions. Other attr
ibutes are | | * directory file in), uses current time and zero permissions. Other attr
ibutes are | |
| * initialized with zeros, comment and extra field with null values. | | * initialized with zeros, comment and extra field with null values. | |
| * | | * | |
| * \sa setFileDateTime() | | * \sa setFileDateTime() | |
| **/ | | **/ | |
| QuaZipNewInfo(const QString& name, const QString& file); | | QuaZipNewInfo(const QString& name, const QString& file); | |
|
| | | /// Initializes the new instance from existing file info. | |
| | | /** Mainly used when copying files between archives. | |
| | | * | |
| | | * Both extra fields are initialized to existing.extra. | |
| | | * @brief QuaZipNewInfo | |
| | | * @param existing | |
| | | */ | |
| | | QuaZipNewInfo(const QuaZipFileInfo &existing); | |
| | | /// Initializes the new instance from existing file info. | |
| | | /** Mainly used when copying files between archives. | |
| | | * | |
| | | * Both extra fields are initialized to existing.extra. | |
| | | * @brief QuaZipNewInfo | |
| | | * @param existing | |
| | | */ | |
| | | QuaZipNewInfo(const QuaZipFileInfo64 &existing); | |
| /// Sets the file timestamp from the existing file. | | /// Sets the file timestamp from the existing file. | |
| /** Use this function to set the file timestamp from the existing | | /** Use this function to set the file timestamp from the existing | |
| * file. Use it like this: | | * file. Use it like this: | |
| * \code | | * \code | |
| * QuaZipFile zipFile(&zip); | | * QuaZipFile zipFile(&zip); | |
| * QFile file("file-to-add"); | | * QFile file("file-to-add"); | |
| * file.open(QIODevice::ReadOnly); | | * file.open(QIODevice::ReadOnly); | |
| * QuaZipNewInfo info("file-name-in-archive"); | | * QuaZipNewInfo info("file-name-in-archive"); | |
| * info.setFileDateTime("file-to-add"); // take the timestamp from file | | * info.setFileDateTime("file-to-add"); // take the timestamp from file | |
| * zipFile.open(QIODevice::WriteOnly, info); | | * zipFile.open(QIODevice::WriteOnly, info); | |
| | | | |
| skipping to change at line 129 | | skipping to change at line 147 | |
| platforms. | | platforms. | |
| */ | | */ | |
| void setFilePermissions(const QString &file); | | void setFilePermissions(const QString &file); | |
| /// Sets the file permissions. | | /// Sets the file permissions. | |
| /** | | /** | |
| Modifies the highest 16 bits of external attributes. The type part | | Modifies the highest 16 bits of external attributes. The type part | |
| is set to dir if the name ends with a slash, and to regular file | | is set to dir if the name ends with a slash, and to regular file | |
| otherwise. | | otherwise. | |
| */ | | */ | |
| void setPermissions(QFile::Permissions permissions); | | void setPermissions(QFile::Permissions permissions); | |
|
| | | /// Sets the NTFS times from an existing file. | |
| | | /** | |
| | | * If the file doesn't exist, a warning is printed to the stderr and noth | |
| | | ing | |
| | | * is done. Otherwise, all three times, as reported by | |
| | | * QFileInfo::lastModified(), QFileInfo::lastRead() and QFileInfo::create | |
| | | d(), | |
| | | * are written to the NTFS extra field record. | |
| | | * | |
| | | * The NTFS record is written to | |
| | | * both the local and the global extra fields, updating the existing reco | |
| | | rd | |
| | | * if there is one, or creating a new one and appending it to the end | |
| | | * of each extra field. | |
| | | * | |
| | | * The microseconds will be zero, as they aren't reported by QFileInfo. | |
| | | * @param fileName | |
| | | */ | |
| | | void setFileNTFSTimes(const QString &fileName); | |
| | | /// Sets the NTFS modification time. | |
| | | /** | |
| | | * The time is written into the NTFS record in | |
| | | * both the local and the global extra fields, updating the existing reco | |
| | | rd | |
| | | * if there is one, or creating a new one and appending it to the end | |
| | | * of each extra field. When updating an existing record, all other field | |
| | | s | |
| | | * are left intact. | |
| | | * @param mTime The new modification time. | |
| | | * @param fineTicks The fractional part of milliseconds, in 100-nanosecon | |
| | | d | |
| | | * ticks (i. e. 9999 ticks = 999.9 microsecond). Values greater th | |
| | | an | |
| | | * 9999 will add milliseconds or even seconds, but this can be | |
| | | * confusing and therefore is discouraged. | |
| | | */ | |
| | | void setFileNTFSmTime(const QDateTime &mTime, int fineTicks = 0); | |
| | | /// Sets the NTFS access time. | |
| | | /** | |
| | | * The time is written into the NTFS record in | |
| | | * both the local and the global extra fields, updating the existing reco | |
| | | rd | |
| | | * if there is one, or creating a new one and appending it to the end | |
| | | * of each extra field. When updating an existing record, all other field | |
| | | s | |
| | | * are left intact. | |
| | | * @param aTime The new access time. | |
| | | * @param fineTicks The fractional part of milliseconds, in 100-nanosecon | |
| | | d | |
| | | * ticks (i. e. 9999 ticks = 999.9 microsecond). Values greater th | |
| | | an | |
| | | * 9999 will add milliseconds or even seconds, but this can be | |
| | | * confusing and therefore is discouraged. | |
| | | */ | |
| | | void setFileNTFSaTime(const QDateTime &aTime, int fineTicks = 0); | |
| | | /// Sets the NTFS creation time. | |
| | | /** | |
| | | * The time is written into the NTFS record in | |
| | | * both the local and the global extra fields, updating the existing reco | |
| | | rd | |
| | | * if there is one, or creating a new one and appending it to the end | |
| | | * of each extra field. When updating an existing record, all other field | |
| | | s | |
| | | * are left intact. | |
| | | * @param cTime The new creation time. | |
| | | * @param fineTicks The fractional part of milliseconds, in 100-nanosecon | |
| | | d | |
| | | * ticks (i. e. 9999 ticks = 999.9 microsecond). Values greater th | |
| | | an | |
| | | * 9999 will add milliseconds or even seconds, but this can be | |
| | | * confusing and therefore is discouraged. | |
| | | */ | |
| | | void setFileNTFScTime(const QDateTime &cTime, int fineTicks = 0); | |
| }; | | }; | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 3 change blocks. |
| 0 lines changed or deleted | | 91 lines changed or added | |
|