diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-06-08 20:25:36 +0200 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-08-07 22:18:41 +0200 |
commit | b0f22620a2dbfb991b10a8e1e8b0c8db5e3ee117 (patch) | |
tree | 2695997733229be38ec71c36753b19ba2e98aa61 | |
parent | b3a0187416e48d80275af6be0178cef155aa03dc (diff) | |
download | rockbox-b0f22620a2dbfb991b10a8e1e8b0c8db5e3ee117.tar.gz rockbox-b0f22620a2dbfb991b10a8e1e8b0c8db5e3ee117.zip |
rbutil: Update quazip to release 0.9.1.
Update to latest quazip release.
Change-Id: I03189ceeadbe3110a9420153d84bd5d33d5b663f
-rw-r--r-- | rbutil/rbutilqt/quazip/README.ROCKBOX | 4 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/ioapi.h | 2 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/minizip_crypt.h (renamed from rbutil/rbutilqt/quazip/crypt.h) | 2 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/qioapi.cpp | 8 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/quazip.cpp | 96 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/quazip.h | 48 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/quazip.pri | 2 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/quazip_global.h | 8 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/quazipfile.cpp | 90 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/quazipfile.h | 54 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/quazipfileinfo.cpp | 146 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/quazipfileinfo.h | 54 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/quazipnewinfo.cpp | 23 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/quazipnewinfo.h | 13 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/unzip.c | 48 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/unzip.h | 5 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/zip.c | 46 | ||||
-rw-r--r-- | rbutil/rbutilqt/quazip/zip.h | 3 |
18 files changed, 489 insertions, 163 deletions
diff --git a/rbutil/rbutilqt/quazip/README.ROCKBOX b/rbutil/rbutilqt/quazip/README.ROCKBOX index b4ffc270ae..a168b2a079 100644 --- a/rbutil/rbutilqt/quazip/README.ROCKBOX +++ b/rbutil/rbutilqt/quazip/README.ROCKBOX | |||
@@ -3,7 +3,7 @@ These files are distributed under the LGPL v2.1 or later. Only source files | |||
3 | actually used in Rockbox Utility are included, further sources have been left | 3 | actually used in Rockbox Utility are included, further sources have been left |
4 | out. Check the quazip source distribution for those. | 4 | out. Check the quazip source distribution for those. |
5 | 5 | ||
6 | The source files have been last synced with the projects release 0.7.1 at | 6 | The source files have been last synced with the projects release 0.9.1 at |
7 | http://sourceforge.net/projects/quazip/ on March 8, 2015. | 7 | https://github.com/stachenov/quazip/ on June 8, 2020. |
8 | 8 | ||
9 | 9 | ||
diff --git a/rbutil/rbutilqt/quazip/ioapi.h b/rbutil/rbutilqt/quazip/ioapi.h index bbb94c8c76..75d0aa6933 100644 --- a/rbutil/rbutilqt/quazip/ioapi.h +++ b/rbutil/rbutilqt/quazip/ioapi.h | |||
@@ -44,7 +44,7 @@ | |||
44 | 44 | ||
45 | #include <stdio.h> | 45 | #include <stdio.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include "zlib.h" | 47 | #include <zlib.h> |
48 | 48 | ||
49 | #if defined(USE_FILE32API) | 49 | #if defined(USE_FILE32API) |
50 | #define fopen64 fopen | 50 | #define fopen64 fopen |
diff --git a/rbutil/rbutilqt/quazip/crypt.h b/rbutil/rbutilqt/quazip/minizip_crypt.h index ddee28e7dd..2e833f7f3c 100644 --- a/rbutil/rbutilqt/quazip/crypt.h +++ b/rbutil/rbutilqt/quazip/minizip_crypt.h | |||
@@ -34,7 +34,7 @@ | |||
34 | /*********************************************************************** | 34 | /*********************************************************************** |
35 | * Return the next byte in the pseudo-random sequence | 35 | * Return the next byte in the pseudo-random sequence |
36 | */ | 36 | */ |
37 | static int decrypt_byte(unsigned long* pkeys, const z_crc_t FAR * pcrc_32_tab UNUSED) | 37 | static int decrypt_byte(unsigned long* pkeys, const z_crc_t FAR * pcrc_32_tab QUAZIP_UNUSED) |
38 | { | 38 | { |
39 | //(void) pcrc_32_tab; /* avoid "unused parameter" warning */ | 39 | //(void) pcrc_32_tab; /* avoid "unused parameter" warning */ |
40 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an | 40 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an |
diff --git a/rbutil/rbutilqt/quazip/qioapi.cpp b/rbutil/rbutilqt/quazip/qioapi.cpp index 534dbdf51f..3932ebeef0 100644 --- a/rbutil/rbutilqt/quazip/qioapi.cpp +++ b/rbutil/rbutilqt/quazip/qioapi.cpp | |||
@@ -11,16 +11,16 @@ | |||
11 | #include <stdio.h> | 11 | #include <stdio.h> |
12 | #include <stdlib.h> | 12 | #include <stdlib.h> |
13 | #include <string.h> | 13 | #include <string.h> |
14 | #include <zlib.h> | ||
14 | 15 | ||
15 | #include "zlib.h" | ||
16 | #include "ioapi.h" | 16 | #include "ioapi.h" |
17 | #include "quazip_global.h" | 17 | #include "quazip_global.h" |
18 | #include <QIODevice> | 18 | #include <QtCore/QIODevice> |
19 | #if (QT_VERSION >= 0x050100) | 19 | #if (QT_VERSION >= 0x050100) |
20 | #define QUAZIP_QSAVEFILE_BUG_WORKAROUND | 20 | #define QUAZIP_QSAVEFILE_BUG_WORKAROUND |
21 | #endif | 21 | #endif |
22 | #ifdef QUAZIP_QSAVEFILE_BUG_WORKAROUND | 22 | #ifdef QUAZIP_QSAVEFILE_BUG_WORKAROUND |
23 | #include <QSaveFile> | 23 | #include <QtCore/QSaveFile> |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ | 26 | /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ |
@@ -75,6 +75,7 @@ ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream | |||
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | /// @cond internal | ||
78 | struct QIODevice_descriptor { | 79 | struct QIODevice_descriptor { |
79 | // Position only used for writing to sequential devices. | 80 | // Position only used for writing to sequential devices. |
80 | qint64 pos; | 81 | qint64 pos; |
@@ -82,6 +83,7 @@ struct QIODevice_descriptor { | |||
82 | pos(0) | 83 | pos(0) |
83 | {} | 84 | {} |
84 | }; | 85 | }; |
86 | /// @endcond | ||
85 | 87 | ||
86 | voidpf ZCALLBACK qiodevice_open_file_func ( | 88 | voidpf ZCALLBACK qiodevice_open_file_func ( |
87 | voidpf opaque, | 89 | voidpf opaque, |
diff --git a/rbutil/rbutilqt/quazip/quazip.cpp b/rbutil/rbutilqt/quazip/quazip.cpp index e3623c76e3..61c2ea87eb 100644 --- a/rbutil/rbutilqt/quazip/quazip.cpp +++ b/rbutil/rbutilqt/quazip/quazip.cpp | |||
@@ -22,12 +22,14 @@ Original ZIP package is copyrighted by Gilles Vollant, see | |||
22 | quazip/(un)zip.h files for details, basically it's zlib license. | 22 | quazip/(un)zip.h files for details, basically it's zlib license. |
23 | **/ | 23 | **/ |
24 | 24 | ||
25 | #include <QFile> | 25 | #include <QtCore/QFile> |
26 | #include <QFlags> | 26 | #include <QtCore/QFlags> |
27 | #include <QHash> | 27 | #include <QtCore/QHash> |
28 | 28 | ||
29 | #include "quazip.h" | 29 | #include "quazip.h" |
30 | 30 | ||
31 | #define QUAZIP_OS_UNIX 3u | ||
32 | |||
31 | /// All the internal stuff for the QuaZip class. | 33 | /// All the internal stuff for the QuaZip class. |
32 | /** | 34 | /** |
33 | \internal | 35 | \internal |
@@ -39,11 +41,12 @@ quazip/(un)zip.h files for details, basically it's zlib license. | |||
39 | class QuaZipPrivate { | 41 | class QuaZipPrivate { |
40 | friend class QuaZip; | 42 | friend class QuaZip; |
41 | private: | 43 | private: |
44 | Q_DISABLE_COPY(QuaZipPrivate) | ||
42 | /// The pointer to the corresponding QuaZip instance. | 45 | /// The pointer to the corresponding QuaZip instance. |
43 | QuaZip *q; | 46 | QuaZip *q; |
44 | /// The codec for file names. | 47 | /// The codec for file names (used when UTF-8 is not enabled). |
45 | QTextCodec *fileNameCodec; | 48 | QTextCodec *fileNameCodec; |
46 | /// The codec for comments. | 49 | /// The codec for comments (used when UTF-8 is not enabled). |
47 | QTextCodec *commentCodec; | 50 | QTextCodec *commentCodec; |
48 | /// The archive file name. | 51 | /// The archive file name. |
49 | QString zipName; | 52 | QString zipName; |
@@ -69,6 +72,10 @@ class QuaZipPrivate { | |||
69 | bool zip64; | 72 | bool zip64; |
70 | /// The auto-close flag. | 73 | /// The auto-close flag. |
71 | bool autoClose; | 74 | bool autoClose; |
75 | /// The UTF-8 flag. | ||
76 | bool utf8; | ||
77 | /// The OS code. | ||
78 | uint osCode; | ||
72 | inline QTextCodec *getDefaultFileNameCodec() | 79 | inline QTextCodec *getDefaultFileNameCodec() |
73 | { | 80 | { |
74 | if (defaultFileNameCodec == NULL) { | 81 | if (defaultFileNameCodec == NULL) { |
@@ -88,8 +95,12 @@ class QuaZipPrivate { | |||
88 | zipError(UNZ_OK), | 95 | zipError(UNZ_OK), |
89 | dataDescriptorWritingEnabled(true), | 96 | dataDescriptorWritingEnabled(true), |
90 | zip64(false), | 97 | zip64(false), |
91 | autoClose(true) | 98 | autoClose(true), |
99 | utf8(false), | ||
100 | osCode(defaultOsCode) | ||
92 | { | 101 | { |
102 | unzFile_f = NULL; | ||
103 | zipFile_f = NULL; | ||
93 | lastMappedDirectoryEntry.num_of_file = 0; | 104 | lastMappedDirectoryEntry.num_of_file = 0; |
94 | lastMappedDirectoryEntry.pos_in_zip_directory = 0; | 105 | lastMappedDirectoryEntry.pos_in_zip_directory = 0; |
95 | } | 106 | } |
@@ -105,14 +116,18 @@ class QuaZipPrivate { | |||
105 | zipError(UNZ_OK), | 116 | zipError(UNZ_OK), |
106 | dataDescriptorWritingEnabled(true), | 117 | dataDescriptorWritingEnabled(true), |
107 | zip64(false), | 118 | zip64(false), |
108 | autoClose(true) | 119 | autoClose(true), |
120 | utf8(false), | ||
121 | osCode(defaultOsCode) | ||
109 | { | 122 | { |
123 | unzFile_f = NULL; | ||
124 | zipFile_f = NULL; | ||
110 | lastMappedDirectoryEntry.num_of_file = 0; | 125 | lastMappedDirectoryEntry.num_of_file = 0; |
111 | lastMappedDirectoryEntry.pos_in_zip_directory = 0; | 126 | lastMappedDirectoryEntry.pos_in_zip_directory = 0; |
112 | } | 127 | } |
113 | /// The constructor for the corresponding QuaZip constructor. | 128 | /// The constructor for the corresponding QuaZip constructor. |
114 | inline QuaZipPrivate(QuaZip *q, QIODevice *ioDevice): | 129 | inline QuaZipPrivate(QuaZip *q, QIODevice *ioDevice): |
115 | q(q), | 130 | q(q), |
116 | fileNameCodec(getDefaultFileNameCodec()), | 131 | fileNameCodec(getDefaultFileNameCodec()), |
117 | commentCodec(QTextCodec::codecForLocale()), | 132 | commentCodec(QTextCodec::codecForLocale()), |
118 | ioDevice(ioDevice), | 133 | ioDevice(ioDevice), |
@@ -121,8 +136,12 @@ class QuaZipPrivate { | |||
121 | zipError(UNZ_OK), | 136 | zipError(UNZ_OK), |
122 | dataDescriptorWritingEnabled(true), | 137 | dataDescriptorWritingEnabled(true), |
123 | zip64(false), | 138 | zip64(false), |
124 | autoClose(true) | 139 | autoClose(true), |
140 | utf8(false), | ||
141 | osCode(defaultOsCode) | ||
125 | { | 142 | { |
143 | unzFile_f = NULL; | ||
144 | zipFile_f = NULL; | ||
126 | lastMappedDirectoryEntry.num_of_file = 0; | 145 | lastMappedDirectoryEntry.num_of_file = 0; |
127 | lastMappedDirectoryEntry.pos_in_zip_directory = 0; | 146 | lastMappedDirectoryEntry.pos_in_zip_directory = 0; |
128 | } | 147 | } |
@@ -138,9 +157,11 @@ class QuaZipPrivate { | |||
138 | QHash<QString, unz64_file_pos> directoryCaseInsensitive; | 157 | QHash<QString, unz64_file_pos> directoryCaseInsensitive; |
139 | unz64_file_pos lastMappedDirectoryEntry; | 158 | unz64_file_pos lastMappedDirectoryEntry; |
140 | static QTextCodec *defaultFileNameCodec; | 159 | static QTextCodec *defaultFileNameCodec; |
160 | static uint defaultOsCode; | ||
141 | }; | 161 | }; |
142 | 162 | ||
143 | QTextCodec *QuaZipPrivate::defaultFileNameCodec = NULL; | 163 | QTextCodec *QuaZipPrivate::defaultFileNameCodec = NULL; |
164 | uint QuaZipPrivate::defaultOsCode = QUAZIP_OS_UNIX; | ||
144 | 165 | ||
145 | void QuaZipPrivate::clearDirectoryMap() | 166 | void QuaZipPrivate::clearDirectoryMap() |
146 | { | 167 | { |
@@ -273,6 +294,8 @@ bool QuaZip::open(Mode mode, zlib_filefunc_def* ioApi) | |||
273 | flags |= ZIP_AUTO_CLOSE; | 294 | flags |= ZIP_AUTO_CLOSE; |
274 | if (p->dataDescriptorWritingEnabled) | 295 | if (p->dataDescriptorWritingEnabled) |
275 | flags |= ZIP_WRITE_DATA_DESCRIPTOR; | 296 | flags |= ZIP_WRITE_DATA_DESCRIPTOR; |
297 | if (p->utf8) | ||
298 | flags |= ZIP_ENCODING_UTF8; | ||
276 | p->zipFile_f=zipOpen3(ioDevice, | 299 | p->zipFile_f=zipOpen3(ioDevice, |
277 | mode==mdCreate?APPEND_STATUS_CREATE: | 300 | mode==mdCreate?APPEND_STATUS_CREATE: |
278 | mode==mdAppend?APPEND_STATUS_CREATEAFTER: | 301 | mode==mdAppend?APPEND_STATUS_CREATEAFTER: |
@@ -334,9 +357,9 @@ void QuaZip::close() | |||
334 | case mdCreate: | 357 | case mdCreate: |
335 | case mdAppend: | 358 | case mdAppend: |
336 | case mdAdd: | 359 | case mdAdd: |
337 | p->zipError=zipClose(p->zipFile_f, | 360 | p->zipError=zipClose(p->zipFile_f, p->comment.isNull() ? NULL : isUtf8Enabled() |
338 | p->comment.isNull() ? NULL | 361 | ? p->comment.toUtf8().constData() |
339 | : p->commentCodec->fromUnicode(p->comment).constData()); | 362 | : p->commentCodec->fromUnicode(p->comment).constData()); |
340 | break; | 363 | break; |
341 | default: | 364 | default: |
342 | qWarning("QuaZip::close(): unknown mode: %d", (int)p->mode); | 365 | qWarning("QuaZip::close(): unknown mode: %d", (int)p->mode); |
@@ -402,7 +425,9 @@ QString QuaZip::getComment()const | |||
402 | if((fakeThis->p->zipError=unzGetGlobalComment(p->unzFile_f, comment.data(), comment.size())) < 0) | 425 | if((fakeThis->p->zipError=unzGetGlobalComment(p->unzFile_f, comment.data(), comment.size())) < 0) |
403 | return QString(); | 426 | return QString(); |
404 | fakeThis->p->zipError = UNZ_OK; | 427 | fakeThis->p->zipError = UNZ_OK; |
405 | return p->commentCodec->toUnicode(comment); | 428 | unsigned flags = 0; |
429 | return (unzGetFileFlags(p->unzFile_f, &flags) == UNZ_OK) && (flags & UNZ_ENCODING_UTF8) | ||
430 | ? QString::fromUtf8(comment) : p->commentCodec->toUnicode(comment); | ||
406 | } | 431 | } |
407 | 432 | ||
408 | bool QuaZip::setCurrentFile(const QString& fileName, CaseSensitivity cs) | 433 | bool QuaZip::setCurrentFile(const QString& fileName, CaseSensitivity cs) |
@@ -537,8 +562,8 @@ bool QuaZip::getCurrentFileInfo(QuaZipFileInfo64 *info)const | |||
537 | info->diskNumberStart=info_z.disk_num_start; | 562 | info->diskNumberStart=info_z.disk_num_start; |
538 | info->internalAttr=info_z.internal_fa; | 563 | info->internalAttr=info_z.internal_fa; |
539 | info->externalAttr=info_z.external_fa; | 564 | info->externalAttr=info_z.external_fa; |
540 | info->name=p->fileNameCodec->toUnicode(fileName); | 565 | info->name=(info->flags & UNZ_ENCODING_UTF8) ? QString::fromUtf8(fileName) : p->fileNameCodec->toUnicode(fileName); |
541 | info->comment=p->commentCodec->toUnicode(comment); | 566 | info->comment=(info->flags & UNZ_ENCODING_UTF8) ? QString::fromUtf8(comment) : p->commentCodec->toUnicode(comment); |
542 | info->extra=extra; | 567 | info->extra=extra; |
543 | info->dateTime=QDateTime( | 568 | info->dateTime=QDateTime( |
544 | QDate(info_z.tmu_date.tm_year, info_z.tmu_date.tm_mon+1, info_z.tmu_date.tm_mday), | 569 | QDate(info_z.tmu_date.tm_year, info_z.tmu_date.tm_mon+1, info_z.tmu_date.tm_mday), |
@@ -558,10 +583,13 @@ QString QuaZip::getCurrentFileName()const | |||
558 | } | 583 | } |
559 | if(!isOpen()||!hasCurrentFile()) return QString(); | 584 | if(!isOpen()||!hasCurrentFile()) return QString(); |
560 | QByteArray fileName(MAX_FILE_NAME_LENGTH, 0); | 585 | QByteArray fileName(MAX_FILE_NAME_LENGTH, 0); |
561 | if((fakeThis->p->zipError=unzGetCurrentFileInfo64(p->unzFile_f, NULL, fileName.data(), fileName.size(), | 586 | unz_file_info64 file_info; |
587 | if((fakeThis->p->zipError=unzGetCurrentFileInfo64(p->unzFile_f, &file_info, fileName.data(), fileName.size(), | ||
562 | NULL, 0, NULL, 0))!=UNZ_OK) | 588 | NULL, 0, NULL, 0))!=UNZ_OK) |
563 | return QString(); | 589 | return QString(); |
564 | QString result = p->fileNameCodec->toUnicode(fileName.constData()); | 590 | fileName.resize(file_info.size_filename); |
591 | QString result = (file_info.flag & UNZ_ENCODING_UTF8) | ||
592 | ? QString::fromUtf8(fileName) : p->fileNameCodec->toUnicode(fileName); | ||
565 | if (result.isEmpty()) | 593 | if (result.isEmpty()) |
566 | return result; | 594 | return result; |
567 | // Add to directory map | 595 | // Add to directory map |
@@ -576,7 +604,17 @@ void QuaZip::setFileNameCodec(QTextCodec *fileNameCodec) | |||
576 | 604 | ||
577 | void QuaZip::setFileNameCodec(const char *fileNameCodecName) | 605 | void QuaZip::setFileNameCodec(const char *fileNameCodecName) |
578 | { | 606 | { |
579 | p->fileNameCodec=QTextCodec::codecForName(fileNameCodecName); | 607 | p->fileNameCodec=QTextCodec::codecForName(fileNameCodecName); |
608 | } | ||
609 | |||
610 | void QuaZip::setOsCode(uint osCode) | ||
611 | { | ||
612 | p->osCode = osCode; | ||
613 | } | ||
614 | |||
615 | uint QuaZip::getOsCode() const | ||
616 | { | ||
617 | return p->osCode; | ||
580 | } | 618 | } |
581 | 619 | ||
582 | QTextCodec *QuaZip::getFileNameCodec()const | 620 | QTextCodec *QuaZip::getFileNameCodec()const |
@@ -747,7 +785,7 @@ QList<QuaZipFileInfo64> QuaZip::getFileInfoList64() const | |||
747 | Qt::CaseSensitivity QuaZip::convertCaseSensitivity(QuaZip::CaseSensitivity cs) | 785 | Qt::CaseSensitivity QuaZip::convertCaseSensitivity(QuaZip::CaseSensitivity cs) |
748 | { | 786 | { |
749 | if (cs == csDefault) { | 787 | if (cs == csDefault) { |
750 | #ifdef Q_WS_WIN | 788 | #ifdef Q_OS_WIN |
751 | return Qt::CaseInsensitive; | 789 | return Qt::CaseInsensitive; |
752 | #else | 790 | #else |
753 | return Qt::CaseSensitive; | 791 | return Qt::CaseSensitive; |
@@ -767,6 +805,16 @@ void QuaZip::setDefaultFileNameCodec(const char *codecName) | |||
767 | setDefaultFileNameCodec(QTextCodec::codecForName(codecName)); | 805 | setDefaultFileNameCodec(QTextCodec::codecForName(codecName)); |
768 | } | 806 | } |
769 | 807 | ||
808 | void QuaZip::setDefaultOsCode(uint osCode) | ||
809 | { | ||
810 | QuaZipPrivate::defaultOsCode = osCode; | ||
811 | } | ||
812 | |||
813 | uint QuaZip::getDefaultOsCode() | ||
814 | { | ||
815 | return QuaZipPrivate::defaultOsCode; | ||
816 | } | ||
817 | |||
770 | void QuaZip::setZip64Enabled(bool zip64) | 818 | void QuaZip::setZip64Enabled(bool zip64) |
771 | { | 819 | { |
772 | p->zip64 = zip64; | 820 | p->zip64 = zip64; |
@@ -777,6 +825,16 @@ bool QuaZip::isZip64Enabled() const | |||
777 | return p->zip64; | 825 | return p->zip64; |
778 | } | 826 | } |
779 | 827 | ||
828 | void QuaZip::setUtf8Enabled(bool utf8) | ||
829 | { | ||
830 | p->utf8 = utf8; | ||
831 | } | ||
832 | |||
833 | bool QuaZip::isUtf8Enabled() const | ||
834 | { | ||
835 | return p->utf8; | ||
836 | } | ||
837 | |||
780 | bool QuaZip::isAutoClose() const | 838 | bool QuaZip::isAutoClose() const |
781 | { | 839 | { |
782 | return p->autoClose; | 840 | return p->autoClose; |
diff --git a/rbutil/rbutilqt/quazip/quazip.h b/rbutil/rbutilqt/quazip/quazip.h index ae2c8f494f..e57a64ae39 100644 --- a/rbutil/rbutilqt/quazip/quazip.h +++ b/rbutil/rbutilqt/quazip/quazip.h | |||
@@ -25,9 +25,9 @@ Original ZIP package is copyrighted by Gilles Vollant, see | |||
25 | quazip/(un)zip.h files for details, basically it's zlib license. | 25 | quazip/(un)zip.h files for details, basically it's zlib license. |
26 | **/ | 26 | **/ |
27 | 27 | ||
28 | #include <QString> | 28 | #include <QtCore/QString> |
29 | #include <QStringList> | 29 | #include <QtCore/QStringList> |
30 | #include <QTextCodec> | 30 | #include <QtCore/QTextCodec> |
31 | 31 | ||
32 | #include "zip.h" | 32 | #include "zip.h" |
33 | #include "unzip.h" | 33 | #include "unzip.h" |
@@ -227,6 +227,14 @@ class QUAZIP_EXPORT QuaZip { | |||
227 | * Equivalent to calling setFileNameCodec(QTextCodec::codecForName(codecName)); | 227 | * Equivalent to calling setFileNameCodec(QTextCodec::codecForName(codecName)); |
228 | **/ | 228 | **/ |
229 | void setFileNameCodec(const char *fileNameCodecName); | 229 | void setFileNameCodec(const char *fileNameCodecName); |
230 | /// Sets the OS code (highest 8 bits of the “version made by” field) for new files. | ||
231 | /** There is currently no way to specify this for each file individually, | ||
232 | except by calling this function before opening each file. If this function is not called, | ||
233 | then the default OS code will be used. The default code is set by calling | ||
234 | setDefaultOsCode(). The default value at the moment of QuaZip creation will be used. */ | ||
235 | void setOsCode(uint osCode); | ||
236 | /// Returns the OS code for new files. | ||
237 | uint getOsCode() const; | ||
230 | /// Returns the codec used to encode/decode comments inside archive. | 238 | /// Returns the codec used to encode/decode comments inside archive. |
231 | QTextCodec* getFileNameCodec() const; | 239 | QTextCodec* getFileNameCodec() const; |
232 | /// Sets the codec used to encode/decode comments inside archive. | 240 | /// Sets the codec used to encode/decode comments inside archive. |
@@ -502,6 +510,28 @@ class QUAZIP_EXPORT QuaZip { | |||
502 | * \sa setZip64Enabled() | 510 | * \sa setZip64Enabled() |
503 | */ | 511 | */ |
504 | bool isZip64Enabled() const; | 512 | bool isZip64Enabled() const; |
513 | /// Enables the use of UTF-8 encoding for file names and comments text. | ||
514 | /** | ||
515 | * @param utf8 If \c true, the UTF-8 mode is enabled, disabled otherwise. | ||
516 | * | ||
517 | * Once this is enabled, the names of all new files and comments text (until | ||
518 | * the mode is disabled again) will be encoded in UTF-8 encoding, and the | ||
519 | * version to extract will be set to 6.3 (63) in ZIP header. By default, | ||
520 | * the UTF-8 mode is off due to compatibility reasons. | ||
521 | * | ||
522 | * Note that when extracting ZIP archives, the UTF-8 mode is determined from | ||
523 | * ZIP file header, not from this flag. | ||
524 | * | ||
525 | * \sa isUtf8Enabled() | ||
526 | */ | ||
527 | void setUtf8Enabled(bool utf8); | ||
528 | /// Returns whether the UTF-8 encoding mode is enabled. | ||
529 | /** | ||
530 | * @return \c true if and only if the UTF-8 mode is enabled. | ||
531 | * | ||
532 | * \sa setUtf8Enabled() | ||
533 | */ | ||
534 | bool isUtf8Enabled() const; | ||
505 | /// Returns the auto-close flag. | 535 | /// Returns the auto-close flag. |
506 | /** | 536 | /** |
507 | @sa setAutoClose() | 537 | @sa setAutoClose() |
@@ -563,9 +593,19 @@ class QUAZIP_EXPORT QuaZip { | |||
563 | /** | 593 | /** |
564 | * @overload | 594 | * @overload |
565 | * Equivalent to calling | 595 | * Equivalent to calling |
566 | * setDefltFileNameCodec(QTextCodec::codecForName(codecName)). | 596 | * setDefaultFileNameCodec(QTextCodec::codecForName(codecName)). |
567 | */ | 597 | */ |
568 | static void setDefaultFileNameCodec(const char *codecName); | 598 | static void setDefaultFileNameCodec(const char *codecName); |
599 | /// Sets default OS code. | ||
600 | /** | ||
601 | * @sa setOsCode() | ||
602 | */ | ||
603 | static void setDefaultOsCode(uint osCode); | ||
604 | /// Returns default OS code. | ||
605 | /** | ||
606 | * @sa getOsCode() | ||
607 | */ | ||
608 | static uint getDefaultOsCode(); | ||
569 | }; | 609 | }; |
570 | 610 | ||
571 | #endif | 611 | #endif |
diff --git a/rbutil/rbutilqt/quazip/quazip.pri b/rbutil/rbutilqt/quazip/quazip.pri index cae9d965c1..3a82bd0275 100644 --- a/rbutil/rbutilqt/quazip/quazip.pri +++ b/rbutil/rbutilqt/quazip/quazip.pri | |||
@@ -9,7 +9,7 @@ SOURCES += \ | |||
9 | $$PWD/zip.c \ | 9 | $$PWD/zip.c \ |
10 | 10 | ||
11 | HEADERS += \ | 11 | HEADERS += \ |
12 | $$PWD/crypt.h \ | 12 | $$PWD/minizip_crypt.h \ |
13 | $$PWD/ioapi.h \ | 13 | $$PWD/ioapi.h \ |
14 | $$PWD/quazipfile.h \ | 14 | $$PWD/quazipfile.h \ |
15 | $$PWD/quazipfileinfo.h \ | 15 | $$PWD/quazipfileinfo.h \ |
diff --git a/rbutil/rbutilqt/quazip/quazip_global.h b/rbutil/rbutilqt/quazip/quazip_global.h index 7e3798afc1..de581bd7c4 100644 --- a/rbutil/rbutilqt/quazip/quazip_global.h +++ b/rbutil/rbutilqt/quazip/quazip_global.h | |||
@@ -48,12 +48,16 @@ see quazip/(un)zip.h files for details. Basically it's the zlib license. | |||
48 | #endif // QUAZIP_STATIC | 48 | #endif // QUAZIP_STATIC |
49 | 49 | ||
50 | #ifdef __GNUC__ | 50 | #ifdef __GNUC__ |
51 | #define UNUSED __attribute__((__unused__)) | 51 | #define QUAZIP_UNUSED __attribute__((__unused__)) |
52 | #else | 52 | #else |
53 | #define UNUSED | 53 | #define QUAZIP_UNUSED |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #define QUAZIP_EXTRA_NTFS_MAGIC 0x000Au | 56 | #define QUAZIP_EXTRA_NTFS_MAGIC 0x000Au |
57 | #define QUAZIP_EXTRA_NTFS_TIME_MAGIC 0x0001u | 57 | #define QUAZIP_EXTRA_NTFS_TIME_MAGIC 0x0001u |
58 | #define QUAZIP_EXTRA_EXT_TIME_MAGIC 0x5455u | ||
59 | #define QUAZIP_EXTRA_EXT_MOD_TIME_FLAG 1 | ||
60 | #define QUAZIP_EXTRA_EXT_AC_TIME_FLAG 2 | ||
61 | #define QUAZIP_EXTRA_EXT_CR_TIME_FLAG 4 | ||
58 | 62 | ||
59 | #endif // QUAZIP_GLOBAL_H | 63 | #endif // QUAZIP_GLOBAL_H |
diff --git a/rbutil/rbutilqt/quazip/quazipfile.cpp b/rbutil/rbutilqt/quazip/quazipfile.cpp index 8d56417698..b984de7279 100644 --- a/rbutil/rbutilqt/quazip/quazipfile.cpp +++ b/rbutil/rbutilqt/quazip/quazipfile.cpp | |||
@@ -24,8 +24,12 @@ quazip/(un)zip.h files for details, basically it's zlib license. | |||
24 | 24 | ||
25 | #include "quazipfile.h" | 25 | #include "quazipfile.h" |
26 | 26 | ||
27 | #include "quazipfileinfo.h" | ||
28 | |||
27 | using namespace std; | 29 | using namespace std; |
28 | 30 | ||
31 | #define QUAZIP_VERSION_MADE_BY 0x1Eu | ||
32 | |||
29 | /// The implementation class for QuaZip. | 33 | /// The implementation class for QuaZip. |
30 | /** | 34 | /** |
31 | \internal | 35 | \internal |
@@ -37,6 +41,7 @@ technique known as the Pimpl (private implementation) idiom. | |||
37 | class QuaZipFilePrivate { | 41 | class QuaZipFilePrivate { |
38 | friend class QuaZipFile; | 42 | friend class QuaZipFile; |
39 | private: | 43 | private: |
44 | Q_DISABLE_COPY(QuaZipFilePrivate) | ||
40 | /// The pointer to the associated QuaZipFile instance. | 45 | /// The pointer to the associated QuaZipFile instance. |
41 | QuaZipFile *q; | 46 | QuaZipFile *q; |
42 | /// The QuaZip object to work with. | 47 | /// The QuaZip object to work with. |
@@ -76,27 +81,55 @@ class QuaZipFilePrivate { | |||
76 | void setZipError(int zipError) const; | 81 | void setZipError(int zipError) const; |
77 | /// The constructor for the corresponding QuaZipFile constructor. | 82 | /// The constructor for the corresponding QuaZipFile constructor. |
78 | inline QuaZipFilePrivate(QuaZipFile *q): | 83 | inline QuaZipFilePrivate(QuaZipFile *q): |
79 | q(q), zip(NULL), internal(true), zipError(UNZ_OK) {} | 84 | q(q), |
85 | zip(NULL), | ||
86 | caseSensitivity(QuaZip::csDefault), | ||
87 | raw(false), | ||
88 | writePos(0), | ||
89 | uncompressedSize(0), | ||
90 | crc(0), | ||
91 | internal(true), | ||
92 | zipError(UNZ_OK) {} | ||
80 | /// The constructor for the corresponding QuaZipFile constructor. | 93 | /// The constructor for the corresponding QuaZipFile constructor. |
81 | inline QuaZipFilePrivate(QuaZipFile *q, const QString &zipName): | 94 | inline QuaZipFilePrivate(QuaZipFile *q, const QString &zipName): |
82 | q(q), internal(true), zipError(UNZ_OK) | 95 | q(q), |
96 | caseSensitivity(QuaZip::csDefault), | ||
97 | raw(false), | ||
98 | writePos(0), | ||
99 | uncompressedSize(0), | ||
100 | crc(0), | ||
101 | internal(true), | ||
102 | zipError(UNZ_OK) | ||
83 | { | 103 | { |
84 | zip=new QuaZip(zipName); | 104 | zip=new QuaZip(zipName); |
85 | } | 105 | } |
86 | /// The constructor for the corresponding QuaZipFile constructor. | 106 | /// The constructor for the corresponding QuaZipFile constructor. |
87 | inline QuaZipFilePrivate(QuaZipFile *q, const QString &zipName, const QString &fileName, | 107 | inline QuaZipFilePrivate(QuaZipFile *q, const QString &zipName, const QString &fileName, |
88 | QuaZip::CaseSensitivity cs): | 108 | QuaZip::CaseSensitivity cs): |
89 | q(q), internal(true), zipError(UNZ_OK) | 109 | q(q), |
110 | raw(false), | ||
111 | writePos(0), | ||
112 | uncompressedSize(0), | ||
113 | crc(0), | ||
114 | internal(true), | ||
115 | zipError(UNZ_OK) | ||
90 | { | 116 | { |
91 | zip=new QuaZip(zipName); | 117 | zip=new QuaZip(zipName); |
92 | this->fileName=fileName; | 118 | this->fileName=fileName; |
93 | if (this->fileName.startsWith('/')) | 119 | if (this->fileName.startsWith(QLatin1String("/"))) |
94 | this->fileName = this->fileName.mid(1); | 120 | this->fileName = this->fileName.mid(1); |
95 | this->caseSensitivity=cs; | 121 | this->caseSensitivity=cs; |
96 | } | 122 | } |
97 | /// The constructor for the QuaZipFile constructor accepting a file name. | 123 | /// The constructor for the QuaZipFile constructor accepting a file name. |
98 | inline QuaZipFilePrivate(QuaZipFile *q, QuaZip *zip): | 124 | inline QuaZipFilePrivate(QuaZipFile *q, QuaZip *zip): |
99 | q(q), zip(zip), internal(false), zipError(UNZ_OK) {} | 125 | q(q), |
126 | zip(zip), | ||
127 | raw(false), | ||
128 | writePos(0), | ||
129 | uncompressedSize(0), | ||
130 | crc(0), | ||
131 | internal(false), | ||
132 | zipError(UNZ_OK) {} | ||
100 | /// The destructor. | 133 | /// The destructor. |
101 | inline ~QuaZipFilePrivate() | 134 | inline ~QuaZipFilePrivate() |
102 | { | 135 | { |
@@ -203,7 +236,7 @@ void QuaZipFile::setFileName(const QString& fileName, QuaZip::CaseSensitivity cs | |||
203 | return; | 236 | return; |
204 | } | 237 | } |
205 | p->fileName=fileName; | 238 | p->fileName=fileName; |
206 | if (p->fileName.startsWith('/')) | 239 | if (p->fileName.startsWith(QLatin1String("/"))) |
207 | p->fileName = p->fileName.mid(1); | 240 | p->fileName = p->fileName.mid(1); |
208 | p->caseSensitivity=cs; | 241 | p->caseSensitivity=cs; |
209 | } | 242 | } |
@@ -310,14 +343,22 @@ bool QuaZipFile::open(OpenMode mode, const QuaZipNewInfo& info, | |||
310 | zipSetFlags(p->zip->getZipFile(), ZIP_WRITE_DATA_DESCRIPTOR); | 343 | zipSetFlags(p->zip->getZipFile(), ZIP_WRITE_DATA_DESCRIPTOR); |
311 | else | 344 | else |
312 | zipClearFlags(p->zip->getZipFile(), ZIP_WRITE_DATA_DESCRIPTOR); | 345 | zipClearFlags(p->zip->getZipFile(), ZIP_WRITE_DATA_DESCRIPTOR); |
313 | p->setZipError(zipOpenNewFileInZip3_64(p->zip->getZipFile(), | 346 | p->setZipError(zipOpenNewFileInZip4_64(p->zip->getZipFile(), |
314 | p->zip->getFileNameCodec()->fromUnicode(info.name).constData(), &info_z, | 347 | p->zip->isUtf8Enabled() |
348 | ? info.name.toUtf8().constData() | ||
349 | : p->zip->getFileNameCodec()->fromUnicode(info.name).constData(), | ||
350 | &info_z, | ||
315 | info.extraLocal.constData(), info.extraLocal.length(), | 351 | info.extraLocal.constData(), info.extraLocal.length(), |
316 | info.extraGlobal.constData(), info.extraGlobal.length(), | 352 | info.extraGlobal.constData(), info.extraGlobal.length(), |
317 | p->zip->getCommentCodec()->fromUnicode(info.comment).constData(), | 353 | p->zip->isUtf8Enabled() |
354 | ? info.comment.toUtf8().constData() | ||
355 | : p->zip->getCommentCodec()->fromUnicode(info.comment).constData(), | ||
318 | method, level, (int)raw, | 356 | method, level, (int)raw, |
319 | windowBits, memLevel, strategy, | 357 | windowBits, memLevel, strategy, |
320 | password, (uLong)crc, p->zip->isZip64Enabled())); | 358 | password, (uLong)crc, |
359 | (p->zip->getOsCode() << 8) | QUAZIP_VERSION_MADE_BY, | ||
360 | 0, | ||
361 | p->zip->isZip64Enabled())); | ||
321 | if(p->zipError==UNZ_OK) { | 362 | if(p->zipError==UNZ_OK) { |
322 | p->writePos=0; | 363 | p->writePos=0; |
323 | setOpenMode(mode); | 364 | setOpenMode(mode); |
@@ -353,7 +394,7 @@ qint64 QuaZipFile::pos()const | |||
353 | // QIODevice::pos() is broken for sequential devices, | 394 | // QIODevice::pos() is broken for sequential devices, |
354 | // but thankfully bytesAvailable() returns the number of | 395 | // but thankfully bytesAvailable() returns the number of |
355 | // bytes buffered, so we know how far ahead we are. | 396 | // bytes buffered, so we know how far ahead we are. |
356 | return unztell(p->zip->getUnzFile()) - QIODevice::bytesAvailable(); | 397 | return unztell64(p->zip->getUnzFile()) - QIODevice::bytesAvailable(); |
357 | else | 398 | else |
358 | return p->writePos; | 399 | return p->writePos; |
359 | } | 400 | } |
@@ -500,3 +541,30 @@ qint64 QuaZipFile::bytesAvailable() const | |||
500 | { | 541 | { |
501 | return size() - pos(); | 542 | return size() - pos(); |
502 | } | 543 | } |
544 | |||
545 | QByteArray QuaZipFile::getLocalExtraField() | ||
546 | { | ||
547 | int size = unzGetLocalExtrafield(p->zip->getUnzFile(), NULL, 0); | ||
548 | QByteArray extra(size, '\0'); | ||
549 | int err = unzGetLocalExtrafield(p->zip->getUnzFile(), extra.data(), static_cast<uint>(extra.size())); | ||
550 | if (err < 0) { | ||
551 | p->setZipError(err); | ||
552 | return QByteArray(); | ||
553 | } | ||
554 | return extra; | ||
555 | } | ||
556 | |||
557 | QDateTime QuaZipFile::getExtModTime() | ||
558 | { | ||
559 | return QuaZipFileInfo64::getExtTime(getLocalExtraField(), QUAZIP_EXTRA_EXT_MOD_TIME_FLAG); | ||
560 | } | ||
561 | |||
562 | QDateTime QuaZipFile::getExtAcTime() | ||
563 | { | ||
564 | return QuaZipFileInfo64::getExtTime(getLocalExtraField(), QUAZIP_EXTRA_EXT_AC_TIME_FLAG); | ||
565 | } | ||
566 | |||
567 | QDateTime QuaZipFile::getExtCrTime() | ||
568 | { | ||
569 | return QuaZipFileInfo64::getExtTime(getLocalExtraField(), QUAZIP_EXTRA_EXT_CR_TIME_FLAG); | ||
570 | } | ||
diff --git a/rbutil/rbutilqt/quazip/quazipfile.h b/rbutil/rbutilqt/quazip/quazipfile.h index e27b7a4a6c..0fd6829f36 100644 --- a/rbutil/rbutilqt/quazip/quazipfile.h +++ b/rbutil/rbutilqt/quazip/quazipfile.h | |||
@@ -25,7 +25,7 @@ Original ZIP package is copyrighted by Gilles Vollant, see | |||
25 | quazip/(un)zip.h files for details, basically it's zlib license. | 25 | quazip/(un)zip.h files for details, basically it's zlib license. |
26 | **/ | 26 | **/ |
27 | 27 | ||
28 | #include <QIODevice> | 28 | #include <QtCore/QIODevice> |
29 | 29 | ||
30 | #include "quazip_global.h" | 30 | #include "quazip_global.h" |
31 | #include "quazip.h" | 31 | #include "quazip.h" |
@@ -451,6 +451,58 @@ class QUAZIP_EXPORT QuaZipFile: public QIODevice { | |||
451 | int getZipError() const; | 451 | int getZipError() const; |
452 | /// Returns the number of bytes available for reading. | 452 | /// Returns the number of bytes available for reading. |
453 | virtual qint64 bytesAvailable() const; | 453 | virtual qint64 bytesAvailable() const; |
454 | /// Returns the local extra field | ||
455 | /** | ||
456 | There are two (optional) local extra fields associated with a file. | ||
457 | One is located in the central header and is available along | ||
458 | with the rest of the file information in @ref QuaZipFileInfo64::extra. | ||
459 | Another is located before the file itself, | ||
460 | and is returned by this function. The file must be open first. | ||
461 | |||
462 | @return the local extra field, or an empty array if there is none | ||
463 | (or file is not open) | ||
464 | */ | ||
465 | QByteArray getLocalExtraField(); | ||
466 | /// Returns the extended modification timestamp | ||
467 | /** | ||
468 | * The getExt*Time() functions only work if there is an extended timestamp | ||
469 | * extra field (ID 0x5455) present. Otherwise, they all return invalid null | ||
470 | * timestamps. | ||
471 | * | ||
472 | * Modification time, but not other times, can also be accessed through | ||
473 | * @ref QuaZipFileInfo64 without the need to open the file first. | ||
474 | * | ||
475 | * @sa dateTime | ||
476 | * @sa QuaZipFileInfo64::getExtModTime() | ||
477 | * @sa getExtAcTime() | ||
478 | * @sa getExtCrTime() | ||
479 | * @return The extended modification time, UTC | ||
480 | */ | ||
481 | QDateTime getExtModTime(); | ||
482 | /// Returns the extended access timestamp | ||
483 | /** | ||
484 | * The getExt*Time() functions only work if there is an extended timestamp | ||
485 | * extra field (ID 0x5455) present. Otherwise, they all return invalid null | ||
486 | * timestamps. | ||
487 | * @sa dateTime | ||
488 | * @sa QuaZipFileInfo64::getExtModTime() | ||
489 | * @sa getExtModTime() | ||
490 | * @sa getExtCrTime() | ||
491 | * @return The extended access time, UTC | ||
492 | */ | ||
493 | QDateTime getExtAcTime(); | ||
494 | /// Returns the extended creation timestamp | ||
495 | /** | ||
496 | * The getExt*Time() functions only work if there is an extended timestamp | ||
497 | * extra field (ID 0x5455) present. Otherwise, they all return invalid null | ||
498 | * timestamps. | ||
499 | * @sa dateTime | ||
500 | * @sa QuaZipFileInfo64::getExtModTime() | ||
501 | * @sa getExtModTime() | ||
502 | * @sa getExtAcTime() | ||
503 | * @return The extended creation time, UTC | ||
504 | */ | ||
505 | QDateTime getExtCrTime(); | ||
454 | }; | 506 | }; |
455 | 507 | ||
456 | #endif | 508 | #endif |
diff --git a/rbutil/rbutilqt/quazip/quazipfileinfo.cpp b/rbutil/rbutilqt/quazip/quazipfileinfo.cpp index 1961f116b3..d5798ea771 100644 --- a/rbutil/rbutilqt/quazip/quazipfileinfo.cpp +++ b/rbutil/rbutilqt/quazip/quazipfileinfo.cpp | |||
@@ -24,6 +24,8 @@ see quazip/(un)zip.h files for details. Basically it's the zlib license. | |||
24 | 24 | ||
25 | #include "quazipfileinfo.h" | 25 | #include "quazipfileinfo.h" |
26 | 26 | ||
27 | #include <QtCore/QDataStream> | ||
28 | |||
27 | static QFile::Permissions permissionsFromExternalAttr(quint32 externalAttr) { | 29 | static QFile::Permissions permissionsFromExternalAttr(quint32 externalAttr) { |
28 | quint32 uPerm = (externalAttr & 0xFFFF0000u) >> 16; | 30 | quint32 uPerm = (externalAttr & 0xFFFF0000u) >> 16; |
29 | QFile::Permissions perm = QFile::Permissions(); | 31 | QFile::Permissions perm = QFile::Permissions(); |
@@ -93,69 +95,30 @@ static QDateTime getNTFSTime(const QByteArray &extra, int position, | |||
93 | int *fineTicks) | 95 | int *fineTicks) |
94 | { | 96 | { |
95 | QDateTime dateTime; | 97 | QDateTime dateTime; |
96 | for (int i = 0; i <= extra.size() - 4; ) { | 98 | QuaExtraFieldHash extraHash = QuaZipFileInfo64::parseExtraField(extra); |
97 | unsigned type = static_cast<unsigned>(static_cast<unsigned char>( | 99 | QList<QByteArray> ntfsExtraFields = extraHash[QUAZIP_EXTRA_NTFS_MAGIC]; |
98 | extra.at(i))) | 100 | if (ntfsExtraFields.isEmpty()) |
99 | | (static_cast<unsigned>(static_cast<unsigned char>( | 101 | return dateTime; |
100 | extra.at(i + 1))) << 8); | 102 | QByteArray ntfsExtraField = ntfsExtraFields.at(0); |
101 | i += 2; | 103 | if (ntfsExtraField.length() <= 4) |
102 | unsigned length = static_cast<unsigned>(static_cast<unsigned char>( | 104 | return dateTime; |
103 | extra.at(i))) | 105 | QByteArray ntfsAttributes = ntfsExtraField.mid(4); |
104 | | (static_cast<unsigned>(static_cast<unsigned char>( | 106 | QuaExtraFieldHash ntfsHash = QuaZipFileInfo64::parseExtraField(ntfsAttributes); |
105 | extra.at(i + 1))) << 8); | 107 | QList<QByteArray> ntfsTimeAttributes = ntfsHash[QUAZIP_EXTRA_NTFS_TIME_MAGIC]; |
106 | i += 2; | 108 | if (ntfsTimeAttributes.isEmpty()) |
107 | if (type == QUAZIP_EXTRA_NTFS_MAGIC && length >= 32) { | 109 | return dateTime; |
108 | i += 4; // reserved | 110 | QByteArray ntfsTimes = ntfsTimeAttributes.at(0); |
109 | while (i <= extra.size() - 4) { | 111 | if (ntfsTimes.size() < 24) |
110 | unsigned tag = static_cast<unsigned>( | 112 | return dateTime; |
111 | static_cast<unsigned char>(extra.at(i))) | 113 | QDataStream timeReader(ntfsTimes); |
112 | | (static_cast<unsigned>( | 114 | timeReader.setByteOrder(QDataStream::LittleEndian); |
113 | static_cast<unsigned char>(extra.at(i + 1))) | 115 | timeReader.device()->seek(position); |
114 | << 8); | 116 | quint64 time; |
115 | i += 2; | 117 | timeReader >> time; |
116 | int tagsize = static_cast<unsigned>( | 118 | QDateTime base(QDate(1601, 1, 1), QTime(0, 0), Qt::UTC); |
117 | static_cast<unsigned char>(extra.at(i))) | 119 | dateTime = base.addMSecs(time / 10000); |
118 | | (static_cast<unsigned>( | 120 | if (fineTicks != NULL) { |
119 | static_cast<unsigned char>(extra.at(i + 1))) | 121 | *fineTicks = static_cast<int>(time % 10000); |
120 | << 8); | ||
121 | i += 2; | ||
122 | if (tag == QUAZIP_EXTRA_NTFS_TIME_MAGIC | ||
123 | && tagsize >= position + 8) { | ||
124 | i += position; | ||
125 | quint64 mtime = static_cast<quint64>( | ||
126 | static_cast<unsigned char>(extra.at(i))) | ||
127 | | (static_cast<quint64>(static_cast<unsigned char>( | ||
128 | extra.at(i + 1))) << 8) | ||
129 | | (static_cast<quint64>(static_cast<unsigned char>( | ||
130 | extra.at(i + 2))) << 16) | ||
131 | | (static_cast<quint64>(static_cast<unsigned char>( | ||
132 | extra.at(i + 3))) << 24) | ||
133 | | (static_cast<quint64>(static_cast<unsigned char>( | ||
134 | extra.at(i + 4))) << 32) | ||
135 | | (static_cast<quint64>(static_cast<unsigned char>( | ||
136 | extra.at(i + 5))) << 40) | ||
137 | | (static_cast<quint64>(static_cast<unsigned char>( | ||
138 | extra.at(i + 6))) << 48) | ||
139 | | (static_cast<quint64>(static_cast<unsigned char>( | ||
140 | extra.at(i + 7))) << 56); | ||
141 | // the NTFS time is measured from 1601 for whatever reason | ||
142 | QDateTime base(QDate(1601, 1, 1), QTime(0, 0), Qt::UTC); | ||
143 | dateTime = base.addMSecs(mtime / 10000); | ||
144 | if (fineTicks != NULL) { | ||
145 | *fineTicks = static_cast<int>(mtime % 10000); | ||
146 | } | ||
147 | i += tagsize - position; | ||
148 | } else { | ||
149 | i += tagsize; | ||
150 | } | ||
151 | |||
152 | } | ||
153 | } else { | ||
154 | i += length; | ||
155 | } | ||
156 | } | ||
157 | if (fineTicks != NULL && dateTime.isNull()) { | ||
158 | *fineTicks = 0; | ||
159 | } | 122 | } |
160 | return dateTime; | 123 | return dateTime; |
161 | } | 124 | } |
@@ -174,3 +137,60 @@ QDateTime QuaZipFileInfo64::getNTFScTime(int *fineTicks) const | |||
174 | { | 137 | { |
175 | return getNTFSTime(extra, 16, fineTicks); | 138 | return getNTFSTime(extra, 16, fineTicks); |
176 | } | 139 | } |
140 | |||
141 | QDateTime QuaZipFileInfo64::getExtTime(const QByteArray &extra, int flag) | ||
142 | { | ||
143 | QDateTime dateTime; | ||
144 | QuaExtraFieldHash extraHash = QuaZipFileInfo64::parseExtraField(extra); | ||
145 | QList<QByteArray> extTimeFields = extraHash[QUAZIP_EXTRA_EXT_TIME_MAGIC]; | ||
146 | if (extTimeFields.isEmpty()) | ||
147 | return dateTime; | ||
148 | QByteArray extTimeField = extTimeFields.at(0); | ||
149 | if (extTimeField.length() < 1) | ||
150 | return dateTime; | ||
151 | QDataStream input(extTimeField); | ||
152 | input.setByteOrder(QDataStream::LittleEndian); | ||
153 | quint8 flags; | ||
154 | input >> flags; | ||
155 | int flagsRemaining = flags; | ||
156 | while (!input.atEnd()) { | ||
157 | int nextFlag = flagsRemaining & -flagsRemaining; | ||
158 | flagsRemaining &= flagsRemaining - 1; | ||
159 | qint32 time; | ||
160 | input >> time; | ||
161 | if (nextFlag == flag) { | ||
162 | QDateTime base(QDate(1970, 1, 1), QTime(0, 0), Qt::UTC); | ||
163 | dateTime = base.addSecs(time); | ||
164 | return dateTime; | ||
165 | } | ||
166 | } | ||
167 | return dateTime; | ||
168 | } | ||
169 | |||
170 | QDateTime QuaZipFileInfo64::getExtModTime() const | ||
171 | { | ||
172 | return getExtTime(extra, 1); | ||
173 | } | ||
174 | |||
175 | QuaExtraFieldHash QuaZipFileInfo64::parseExtraField(const QByteArray &extraField) | ||
176 | { | ||
177 | QDataStream input(extraField); | ||
178 | input.setByteOrder(QDataStream::LittleEndian); | ||
179 | QHash<quint16, QList<QByteArray> > result; | ||
180 | while (!input.atEnd()) { | ||
181 | quint16 id, size; | ||
182 | input >> id; | ||
183 | if (input.status() == QDataStream::ReadPastEnd) | ||
184 | return result; | ||
185 | input >> size; | ||
186 | if (input.status() == QDataStream::ReadPastEnd) | ||
187 | return result; | ||
188 | QByteArray data; | ||
189 | data.resize(size); | ||
190 | int read = input.readRawData(data.data(), data.size()); | ||
191 | if (read < data.size()) | ||
192 | return result; | ||
193 | result[id] << data; | ||
194 | } | ||
195 | return result; | ||
196 | } | ||
diff --git a/rbutil/rbutilqt/quazip/quazipfileinfo.h b/rbutil/rbutilqt/quazip/quazipfileinfo.h index 4e142a4eb5..43665b4ac2 100644 --- a/rbutil/rbutilqt/quazip/quazipfileinfo.h +++ b/rbutil/rbutilqt/quazip/quazipfileinfo.h | |||
@@ -25,12 +25,16 @@ Original ZIP package is copyrighted by Gilles Vollant and contributors, | |||
25 | see quazip/(un)zip.h files for details. Basically it's the zlib license. | 25 | see quazip/(un)zip.h files for details. Basically it's the zlib license. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <QByteArray> | 28 | #include <QtCore/QByteArray> |
29 | #include <QDateTime> | 29 | #include <QtCore/QDateTime> |
30 | #include <QFile> | 30 | #include <QtCore/QFile> |
31 | #include <QtCore/QHash> | ||
31 | 32 | ||
32 | #include "quazip_global.h" | 33 | #include "quazip_global.h" |
33 | 34 | ||
35 | /// The typedef to store extra field parse results | ||
36 | typedef QHash<quint16, QList<QByteArray> > QuaExtraFieldHash; | ||
37 | |||
34 | /// Information about a file inside archive. | 38 | /// Information about a file inside archive. |
35 | /** | 39 | /** |
36 | * \deprecated Use QuaZipFileInfo64 instead. Not only it supports large files, | 40 | * \deprecated Use QuaZipFileInfo64 instead. Not only it supports large files, |
@@ -171,8 +175,52 @@ struct QUAZIP_EXPORT QuaZipFileInfo64 { | |||
171 | * @return The NTFS creation time, UTC | 175 | * @return The NTFS creation time, UTC |
172 | */ | 176 | */ |
173 | QDateTime getNTFScTime(int *fineTicks = NULL) const; | 177 | QDateTime getNTFScTime(int *fineTicks = NULL) const; |
178 | /// Returns the extended modification timestamp | ||
179 | /** | ||
180 | * The getExt*Time() functions only work if there is an extended timestamp | ||
181 | * extra field (ID 0x5455) present. Otherwise, they all return invalid null | ||
182 | * timestamps. | ||
183 | * | ||
184 | * QuaZipFileInfo64 only contains the modification time because it's extracted | ||
185 | * from @ref extra, which contains the global extra field, and access and | ||
186 | * creation time are in the local header which can be accessed through | ||
187 | * @ref QuaZipFile. | ||
188 | * | ||
189 | * @sa dateTime | ||
190 | * @sa QuaZipFile::getExtModTime() | ||
191 | * @sa QuaZipFile::getExtAcTime() | ||
192 | * @sa QuaZipFile::getExtCrTime() | ||
193 | * @return The extended modification time, UTC | ||
194 | */ | ||
195 | QDateTime getExtModTime() const; | ||
174 | /// Checks whether the file is encrypted. | 196 | /// Checks whether the file is encrypted. |
175 | bool isEncrypted() const {return (flags & 1) != 0;} | 197 | bool isEncrypted() const {return (flags & 1) != 0;} |
198 | /// Parses extra field | ||
199 | /** | ||
200 | * The returned hash table contains a list of data blocks for every header ID | ||
201 | * in the provided extra field. The number of data blocks in a hash table value | ||
202 | * equals to the number of occurrences of the appropriate header id. In most cases, | ||
203 | * a block with a specific header ID only occurs once, and therefore the returned | ||
204 | * hash table will contain a list consisting of a single element for that header ID. | ||
205 | * | ||
206 | * @param extraField extra field to parse | ||
207 | * @return header id to list of data block hash | ||
208 | */ | ||
209 | static QuaExtraFieldHash parseExtraField(const QByteArray &extraField); | ||
210 | /// Extracts extended time from the extra field | ||
211 | /** | ||
212 | * Utility function used by various getExt*Time() functions, but can be used directly | ||
213 | * if the extra field is obtained elsewhere (from a third party library, for example). | ||
214 | * | ||
215 | * @param extra the extra field for a file | ||
216 | * @param flag 1 - modification time, 2 - access time, 4 - creation time | ||
217 | * @return the extracted time or null QDateTime if not present | ||
218 | * @sa getExtModTime() | ||
219 | * @sa QuaZipFile::getExtModTime() | ||
220 | * @sa QuaZipFile::getExtAcTime() | ||
221 | * @sa QuaZipFile::getExtCrTime() | ||
222 | */ | ||
223 | static QDateTime getExtTime(const QByteArray &extra, int flag); | ||
176 | }; | 224 | }; |
177 | 225 | ||
178 | #endif | 226 | #endif |
diff --git a/rbutil/rbutilqt/quazip/quazipnewinfo.cpp b/rbutil/rbutilqt/quazip/quazipnewinfo.cpp index 02e01da9c5..98630e086a 100644 --- a/rbutil/rbutilqt/quazip/quazipnewinfo.cpp +++ b/rbutil/rbutilqt/quazip/quazipnewinfo.cpp | |||
@@ -22,16 +22,25 @@ Original ZIP package is copyrighted by Gilles Vollant and contributors, | |||
22 | see quazip/(un)zip.h files for details. Basically it's the zlib license. | 22 | see quazip/(un)zip.h files for details. Basically it's the zlib license. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <QFileInfo> | 25 | #include <QtCore/QFileInfo> |
26 | 26 | ||
27 | #include "quazipnewinfo.h" | 27 | #include "quazipnewinfo.h" |
28 | 28 | ||
29 | #include <string.h> | 29 | #include <string.h> |
30 | 30 | ||
31 | static void QuaZipNewInfo_setPermissions(QuaZipNewInfo *info, | 31 | static void QuaZipNewInfo_setPermissions(QuaZipNewInfo *info, |
32 | QFile::Permissions perm, bool isDir) | 32 | QFile::Permissions perm, bool isDir, bool isSymLink = false) |
33 | { | 33 | { |
34 | quint32 uPerm = isDir ? 0040000 : 0100000; | 34 | quint32 uPerm = isDir ? 0040000 : 0100000; |
35 | |||
36 | if ( isSymLink ) { | ||
37 | #ifdef Q_OS_WIN | ||
38 | uPerm = 0200000; | ||
39 | #else | ||
40 | uPerm = 0120000; | ||
41 | #endif | ||
42 | } | ||
43 | |||
35 | if ((perm & QFile::ReadOwner) != 0) | 44 | if ((perm & QFile::ReadOwner) != 0) |
36 | uPerm |= 0400; | 45 | uPerm |= 0400; |
37 | if ((perm & QFile::WriteOwner) != 0) | 46 | if ((perm & QFile::WriteOwner) != 0) |
@@ -91,7 +100,7 @@ QuaZipNewInfo::QuaZipNewInfo(const QString& name, const QString& file): | |||
91 | dateTime = QDateTime::currentDateTime(); | 100 | dateTime = QDateTime::currentDateTime(); |
92 | } else { | 101 | } else { |
93 | dateTime = lm; | 102 | dateTime = lm; |
94 | QuaZipNewInfo_setPermissions(this, info.permissions(), info.isDir()); | 103 | QuaZipNewInfo_setPermissions(this, info.permissions(), info.isDir(), info.isSymLink()); |
95 | } | 104 | } |
96 | } | 105 | } |
97 | 106 | ||
@@ -107,12 +116,12 @@ void QuaZipNewInfo::setFilePermissions(const QString &file) | |||
107 | { | 116 | { |
108 | QFileInfo info = QFileInfo(file); | 117 | QFileInfo info = QFileInfo(file); |
109 | QFile::Permissions perm = info.permissions(); | 118 | QFile::Permissions perm = info.permissions(); |
110 | QuaZipNewInfo_setPermissions(this, perm, info.isDir()); | 119 | QuaZipNewInfo_setPermissions(this, perm, info.isDir(), info.isSymLink()); |
111 | } | 120 | } |
112 | 121 | ||
113 | void QuaZipNewInfo::setPermissions(QFile::Permissions permissions) | 122 | void QuaZipNewInfo::setPermissions(QFile::Permissions permissions) |
114 | { | 123 | { |
115 | QuaZipNewInfo_setPermissions(this, permissions, name.endsWith('/')); | 124 | QuaZipNewInfo_setPermissions(this, permissions, name.endsWith(QLatin1String("/"))); |
116 | } | 125 | } |
117 | 126 | ||
118 | void QuaZipNewInfo::setFileNTFSTimes(const QString &fileName) | 127 | void QuaZipNewInfo::setFileNTFSTimes(const QString &fileName) |
@@ -125,7 +134,11 @@ void QuaZipNewInfo::setFileNTFSTimes(const QString &fileName) | |||
125 | } | 134 | } |
126 | setFileNTFSmTime(fi.lastModified()); | 135 | setFileNTFSmTime(fi.lastModified()); |
127 | setFileNTFSaTime(fi.lastRead()); | 136 | setFileNTFSaTime(fi.lastRead()); |
137 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) | ||
138 | setFileNTFScTime(fi.birthTime()); | ||
139 | #else | ||
128 | setFileNTFScTime(fi.created()); | 140 | setFileNTFScTime(fi.created()); |
141 | #endif | ||
129 | } | 142 | } |
130 | 143 | ||
131 | static void setNTFSTime(QByteArray &extra, const QDateTime &time, int position, | 144 | static void setNTFSTime(QByteArray &extra, const QDateTime &time, int position, |
diff --git a/rbutil/rbutilqt/quazip/quazipnewinfo.h b/rbutil/rbutilqt/quazip/quazipnewinfo.h index bfd498682f..43a1e6fd08 100644 --- a/rbutil/rbutilqt/quazip/quazipnewinfo.h +++ b/rbutil/rbutilqt/quazip/quazipnewinfo.h | |||
@@ -25,9 +25,9 @@ Original ZIP package is copyrighted by Gilles Vollant, see | |||
25 | quazip/(un)zip.h files for details, basically it's zlib license. | 25 | quazip/(un)zip.h files for details, basically it's zlib license. |
26 | **/ | 26 | **/ |
27 | 27 | ||
28 | #include <QDateTime> | 28 | #include <QtCore/QDateTime> |
29 | #include <QFile> | 29 | #include <QtCore/QFile> |
30 | #include <QString> | 30 | #include <QtCore/QString> |
31 | 31 | ||
32 | #include "quazip_global.h" | 32 | #include "quazip_global.h" |
33 | 33 | ||
@@ -70,7 +70,7 @@ struct QUAZIP_EXPORT QuaZipNewInfo { | |||
70 | */ | 70 | */ |
71 | quint32 externalAttr; | 71 | quint32 externalAttr; |
72 | /// File comment. | 72 | /// File comment. |
73 | /** Will be encoded using QuaZip::getCommentCodec(). | 73 | /** Will be encoded in UTF-8 encoding. |
74 | **/ | 74 | **/ |
75 | QString comment; | 75 | QString comment; |
76 | /// File local extra field. | 76 | /// File local extra field. |
@@ -148,8 +148,9 @@ struct QUAZIP_EXPORT QuaZipNewInfo { | |||
148 | /** | 148 | /** |
149 | * If the file doesn't exist, a warning is printed to the stderr and nothing | 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 | 150 | * is done. Otherwise, all three times, as reported by |
151 | * QFileInfo::lastModified(), QFileInfo::lastRead() and QFileInfo::created(), | 151 | * QFileInfo::lastModified(), QFileInfo::lastRead() and |
152 | * are written to the NTFS extra field record. | 152 | * QFileInfo::birthTime() (>=Qt5.10) or QFileInfo::created(), are written to |
153 | * the NTFS extra field record. | ||
153 | * | 154 | * |
154 | * The NTFS record is written to | 155 | * The NTFS record is written to |
155 | * both the local and the global extra fields, updating the existing record | 156 | * both the local and the global extra fields, updating the existing record |
diff --git a/rbutil/rbutilqt/quazip/unzip.c b/rbutil/rbutilqt/quazip/unzip.c index bca03f8323..6aaeba6930 100644 --- a/rbutil/rbutilqt/quazip/unzip.c +++ b/rbutil/rbutilqt/quazip/unzip.c | |||
@@ -15,6 +15,8 @@ | |||
15 | 15 | ||
16 | For more info read MiniZip_info.txt | 16 | For more info read MiniZip_info.txt |
17 | 17 | ||
18 | Modifications for static code analysis report | ||
19 | Copyright (C) 2016 Intel Deutschland GmbH | ||
18 | 20 | ||
19 | ------------------------------------------------------------------------------------ | 21 | ------------------------------------------------------------------------------------ |
20 | Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of | 22 | Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of |
@@ -28,7 +30,7 @@ | |||
28 | If, for some reason, all these files are missing, the Info-ZIP license | 30 | If, for some reason, all these files are missing, the Info-ZIP license |
29 | also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html | 31 | also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html |
30 | 32 | ||
31 | crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] | 33 | crypt.c (full version) by Info-ZIP. Last revised: [see minizip_crypt.h] |
32 | 34 | ||
33 | The encryption/decryption parts of this source code (as opposed to the | 35 | The encryption/decryption parts of this source code (as opposed to the |
34 | non-echoing password parts) were originally written in Europe. The | 36 | non-echoing password parts) were originally written in Europe. The |
@@ -71,7 +73,7 @@ | |||
71 | #include <stdlib.h> | 73 | #include <stdlib.h> |
72 | #include <string.h> | 74 | #include <string.h> |
73 | 75 | ||
74 | #include "zlib.h" | 76 | #include <zlib.h> |
75 | #if (ZLIB_VERNUM < 0x1270) | 77 | #if (ZLIB_VERNUM < 0x1270) |
76 | typedef uLongf z_crc_t; | 78 | typedef uLongf z_crc_t; |
77 | #endif | 79 | #endif |
@@ -197,7 +199,7 @@ typedef struct | |||
197 | 199 | ||
198 | 200 | ||
199 | #ifndef NOUNCRYPT | 201 | #ifndef NOUNCRYPT |
200 | #include "crypt.h" | 202 | #include "minizip_crypt.h" |
201 | #endif | 203 | #endif |
202 | 204 | ||
203 | /* =========================================================================== | 205 | /* =========================================================================== |
@@ -856,6 +858,17 @@ extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info | |||
856 | pglobal_info32->size_comment = s->gi.size_comment; | 858 | pglobal_info32->size_comment = s->gi.size_comment; |
857 | return UNZ_OK; | 859 | return UNZ_OK; |
858 | } | 860 | } |
861 | |||
862 | extern int ZEXPORT unzGetFileFlags (unzFile file, unsigned* pflags) | ||
863 | { | ||
864 | unz64_s* s; | ||
865 | if (file==NULL) | ||
866 | return UNZ_PARAMERROR; | ||
867 | s=(unz64_s*)file; | ||
868 | *pflags = s->flags; | ||
869 | return UNZ_OK; | ||
870 | } | ||
871 | |||
859 | /* | 872 | /* |
860 | Translate date/time from Dos format to tm_unz (readable more easilty) | 873 | Translate date/time from Dos format to tm_unz (readable more easilty) |
861 | */ | 874 | */ |
@@ -1198,6 +1211,8 @@ extern int ZEXPORT unzGoToFirstFile (unzFile file) | |||
1198 | &s->cur_file_info_internal, | 1211 | &s->cur_file_info_internal, |
1199 | NULL,0,NULL,0,NULL,0); | 1212 | NULL,0,NULL,0,NULL,0); |
1200 | s->current_file_ok = (err == UNZ_OK); | 1213 | s->current_file_ok = (err == UNZ_OK); |
1214 | if (s->cur_file_info.flag & UNZ_ENCODING_UTF8) | ||
1215 | unzSetFlags(file, UNZ_ENCODING_UTF8); | ||
1201 | return err; | 1216 | return err; |
1202 | } | 1217 | } |
1203 | 1218 | ||
@@ -1594,6 +1609,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, | |||
1594 | pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; | 1609 | pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; |
1595 | else | 1610 | else |
1596 | { | 1611 | { |
1612 | TRYFREE(pfile_in_zip_read_info->read_buffer); | ||
1597 | TRYFREE(pfile_in_zip_read_info); | 1613 | TRYFREE(pfile_in_zip_read_info); |
1598 | return err; | 1614 | return err; |
1599 | } | 1615 | } |
@@ -1845,38 +1861,30 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) | |||
1845 | } /* end Z_BZIP2ED */ | 1861 | } /* end Z_BZIP2ED */ |
1846 | else | 1862 | else |
1847 | { | 1863 | { |
1848 | ZPOS64_T uTotalOutBefore,uTotalOutAfter; | 1864 | uInt uAvailOutBefore,uAvailOutAfter; |
1849 | const Bytef *bufBefore; | 1865 | const Bytef *bufBefore; |
1850 | ZPOS64_T uOutThis; | 1866 | uInt uOutThis; |
1851 | int flush=Z_SYNC_FLUSH; | 1867 | int flush=Z_SYNC_FLUSH; |
1852 | 1868 | ||
1853 | uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; | 1869 | uAvailOutBefore = pfile_in_zip_read_info->stream.avail_out; |
1854 | bufBefore = pfile_in_zip_read_info->stream.next_out; | 1870 | bufBefore = pfile_in_zip_read_info->stream.next_out; |
1855 | 1871 | ||
1856 | /* | ||
1857 | if ((pfile_in_zip_read_info->rest_read_uncompressed == | ||
1858 | pfile_in_zip_read_info->stream.avail_out) && | ||
1859 | (pfile_in_zip_read_info->rest_read_compressed == 0)) | ||
1860 | flush = Z_FINISH; | ||
1861 | */ | ||
1862 | err=inflate(&pfile_in_zip_read_info->stream,flush); | 1872 | err=inflate(&pfile_in_zip_read_info->stream,flush); |
1863 | 1873 | ||
1864 | if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) | 1874 | if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) |
1865 | err = Z_DATA_ERROR; | 1875 | err = Z_DATA_ERROR; |
1866 | 1876 | ||
1867 | uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; | 1877 | uAvailOutAfter = pfile_in_zip_read_info->stream.avail_out; |
1868 | uOutThis = uTotalOutAfter-uTotalOutBefore; | 1878 | uOutThis = uAvailOutBefore - uAvailOutAfter; |
1869 | 1879 | ||
1870 | pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; | 1880 | pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; |
1871 | 1881 | ||
1872 | pfile_in_zip_read_info->crc32 = | 1882 | pfile_in_zip_read_info->crc32 |
1873 | crc32(pfile_in_zip_read_info->crc32,bufBefore, | 1883 | = crc32(pfile_in_zip_read_info->crc32,bufBefore, uOutThis); |
1874 | (uInt)(uOutThis)); | ||
1875 | 1884 | ||
1876 | pfile_in_zip_read_info->rest_read_uncompressed -= | 1885 | pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; |
1877 | uOutThis; | ||
1878 | 1886 | ||
1879 | iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); | 1887 | iRead += uAvailOutBefore - uAvailOutAfter; |
1880 | 1888 | ||
1881 | if (err==Z_STREAM_END) | 1889 | if (err==Z_STREAM_END) |
1882 | return (iRead==0) ? UNZ_EOF : iRead; | 1890 | return (iRead==0) ? UNZ_EOF : iRead; |
diff --git a/rbutil/rbutilqt/quazip/unzip.h b/rbutil/rbutilqt/quazip/unzip.h index da7b062845..fdefa2217a 100644 --- a/rbutil/rbutilqt/quazip/unzip.h +++ b/rbutil/rbutilqt/quazip/unzip.h | |||
@@ -53,7 +53,7 @@ extern "C" { | |||
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | #ifndef _ZLIB_H | 55 | #ifndef _ZLIB_H |
56 | #include "zlib.h" | 56 | #include <zlib.h> |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | #ifndef _ZLIBIOAPI_H | 59 | #ifndef _ZLIBIOAPI_H |
@@ -87,6 +87,7 @@ typedef voidp unzFile; | |||
87 | 87 | ||
88 | #define UNZ_AUTO_CLOSE 0x01u | 88 | #define UNZ_AUTO_CLOSE 0x01u |
89 | #define UNZ_DEFAULT_FLAGS UNZ_AUTO_CLOSE | 89 | #define UNZ_DEFAULT_FLAGS UNZ_AUTO_CLOSE |
90 | #define UNZ_ENCODING_UTF8 0x0800u | ||
90 | 91 | ||
91 | /* tm_unz contain date/time info */ | 92 | /* tm_unz contain date/time info */ |
92 | typedef struct tm_unz_s | 93 | typedef struct tm_unz_s |
@@ -227,6 +228,8 @@ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, | |||
227 | 228 | ||
228 | extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, | 229 | extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, |
229 | unz_global_info64 *pglobal_info)); | 230 | unz_global_info64 *pglobal_info)); |
231 | |||
232 | extern int ZEXPORT unzGetFileFlags OF((unzFile file, unsigned* pflags)); | ||
230 | /* | 233 | /* |
231 | Write info about the ZipFile in the *pglobal_info structure. | 234 | Write info about the ZipFile in the *pglobal_info structure. |
232 | No preparation of the structure is needed | 235 | No preparation of the structure is needed |
diff --git a/rbutil/rbutilqt/quazip/zip.c b/rbutil/rbutilqt/quazip/zip.c index 96496539f4..0f3deb04c1 100644 --- a/rbutil/rbutilqt/quazip/zip.c +++ b/rbutil/rbutilqt/quazip/zip.c | |||
@@ -12,6 +12,9 @@ | |||
12 | Modifications for QIODevice support and other QuaZIP fixes | 12 | Modifications for QIODevice support and other QuaZIP fixes |
13 | Copyright (C) 2005-2014 Sergey A. Tachenov | 13 | Copyright (C) 2005-2014 Sergey A. Tachenov |
14 | 14 | ||
15 | Fixing static code analysis issues | ||
16 | Copyright (C) 2016 Intel Deutschland GmbH | ||
17 | |||
15 | Changes | 18 | Changes |
16 | Oct-2009 - Mathias Svensson - Remove old C style function prototypes | 19 | Oct-2009 - Mathias Svensson - Remove old C style function prototypes |
17 | Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives | 20 | Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives |
@@ -29,7 +32,8 @@ | |||
29 | #include <stdlib.h> | 32 | #include <stdlib.h> |
30 | #include <string.h> | 33 | #include <string.h> |
31 | #include <time.h> | 34 | #include <time.h> |
32 | #include "zlib.h" | 35 | |
36 | #include <zlib.h> | ||
33 | #if (ZLIB_VERNUM < 0x1270) | 37 | #if (ZLIB_VERNUM < 0x1270) |
34 | typedef uLongf z_crc_t; | 38 | typedef uLongf z_crc_t; |
35 | #endif | 39 | #endif |
@@ -192,7 +196,7 @@ typedef struct | |||
192 | 196 | ||
193 | #ifndef NOCRYPT | 197 | #ifndef NOCRYPT |
194 | #define INCLUDECRYPTINGCODE_IFCRYPTALLOWED | 198 | #define INCLUDECRYPTINGCODE_IFCRYPTALLOWED |
195 | #include "crypt.h" | 199 | #include "minizip_crypt.h" |
196 | #endif | 200 | #endif |
197 | 201 | ||
198 | local linkedlist_datablock_internal* allocate_new_datablock() | 202 | local linkedlist_datablock_internal* allocate_new_datablock() |
@@ -527,13 +531,14 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f | |||
527 | if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) | 531 | if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) |
528 | break; | 532 | break; |
529 | 533 | ||
530 | for (i=(int)uReadSize-3; (i--)>0;) | 534 | for (i=(int)uReadSize-3; (i--)>0;){ |
531 | if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && | 535 | if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && |
532 | ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) | 536 | ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) |
533 | { | 537 | { |
534 | uPosFound = uReadPos+i; | 538 | uPosFound = uReadPos+i; |
535 | break; | 539 | break; |
536 | } | 540 | } |
541 | } | ||
537 | 542 | ||
538 | if (uPosFound!=0) | 543 | if (uPosFound!=0) |
539 | break; | 544 | break; |
@@ -988,7 +993,9 @@ int Write_LocalFileHeader(zip64_internal* zi, const char* filename, | |||
988 | 993 | ||
989 | if (err==ZIP_OK) | 994 | if (err==ZIP_OK) |
990 | { | 995 | { |
991 | if(zi->ci.zip64) | 996 | if(zi->ci.flag & ZIP_ENCODING_UTF8) |
997 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)63,2);/* Version 6.3 is required for Unicode support */ | ||
998 | else if(zi->ci.zip64) | ||
992 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);/* version needed to extract */ | 999 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);/* version needed to extract */ |
993 | else | 1000 | else |
994 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)version_to_extract,2); | 1001 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)version_to_extract,2); |
@@ -1146,6 +1153,8 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, | |||
1146 | } | 1153 | } |
1147 | 1154 | ||
1148 | zi->ci.flag = flagBase; | 1155 | zi->ci.flag = flagBase; |
1156 | if (zi->flags & ZIP_ENCODING_UTF8) | ||
1157 | zi->ci.flag |= ZIP_ENCODING_UTF8; | ||
1149 | if ((level==8) || (level==9)) | 1158 | if ((level==8) || (level==9)) |
1150 | zi->ci.flag |= 2; | 1159 | zi->ci.flag |= 2; |
1151 | if (level==2) | 1160 | if (level==2) |
@@ -1171,6 +1180,9 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, | |||
1171 | zi->ci.size_centralExtraFree = 32; /* Extra space we have reserved in case we need to add ZIP64 extra info data */ | 1180 | zi->ci.size_centralExtraFree = 32; /* Extra space we have reserved in case we need to add ZIP64 extra info data */ |
1172 | 1181 | ||
1173 | zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader + zi->ci.size_centralExtraFree); | 1182 | zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader + zi->ci.size_centralExtraFree); |
1183 | if(!zi->ci.central_header) { | ||
1184 | return (Z_MEM_ERROR); | ||
1185 | } | ||
1174 | 1186 | ||
1175 | zi->ci.size_centralExtra = size_extrafield_global; | 1187 | zi->ci.size_centralExtra = size_extrafield_global; |
1176 | zip64local_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); | 1188 | zip64local_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); |
@@ -1509,15 +1521,9 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in | |||
1509 | 1521 | ||
1510 | if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) | 1522 | if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) |
1511 | { | 1523 | { |
1512 | uLong uTotalOutBefore = zi->ci.stream.total_out; | 1524 | uInt uAvailOutBefore = zi->ci.stream.avail_out; |
1513 | err=deflate(&zi->ci.stream, Z_NO_FLUSH); | 1525 | err=deflate(&zi->ci.stream, Z_NO_FLUSH); |
1514 | if(uTotalOutBefore > zi->ci.stream.total_out) | 1526 | zi->ci.pos_in_buffered_data += uAvailOutBefore - zi->ci.stream.avail_out; |
1515 | { | ||
1516 | int bBreak = 0; | ||
1517 | bBreak++; | ||
1518 | } | ||
1519 | |||
1520 | zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; | ||
1521 | } | 1527 | } |
1522 | else | 1528 | else |
1523 | { | 1529 | { |
@@ -1571,7 +1577,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s | |||
1571 | { | 1577 | { |
1572 | while (err==ZIP_OK) | 1578 | while (err==ZIP_OK) |
1573 | { | 1579 | { |
1574 | uLong uTotalOutBefore; | 1580 | uLong uAvailOutBefore; |
1575 | if (zi->ci.stream.avail_out == 0) | 1581 | if (zi->ci.stream.avail_out == 0) |
1576 | { | 1582 | { |
1577 | if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) | 1583 | if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) |
@@ -1579,9 +1585,9 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s | |||
1579 | zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; | 1585 | zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; |
1580 | zi->ci.stream.next_out = zi->ci.buffered_data; | 1586 | zi->ci.stream.next_out = zi->ci.buffered_data; |
1581 | } | 1587 | } |
1582 | uTotalOutBefore = zi->ci.stream.total_out; | 1588 | uAvailOutBefore = zi->ci.stream.avail_out; |
1583 | err=deflate(&zi->ci.stream, Z_FINISH); | 1589 | err=deflate(&zi->ci.stream, Z_FINISH); |
1584 | zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; | 1590 | zi->ci.pos_in_buffered_data += uAvailOutBefore - zi->ci.stream.avail_out; |
1585 | } | 1591 | } |
1586 | } | 1592 | } |
1587 | else if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) | 1593 | else if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) |
@@ -1654,8 +1660,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s | |||
1654 | /*version Made by*/ | 1660 | /*version Made by*/ |
1655 | zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)45,2); | 1661 | zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)45,2); |
1656 | /*version needed*/ | 1662 | /*version needed*/ |
1657 | zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)45,2); | 1663 | zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)((zi->ci.flag & ZIP_ENCODING_UTF8) ? 63 : 45),2); |
1658 | |||
1659 | } | 1664 | } |
1660 | 1665 | ||
1661 | zip64local_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ | 1666 | zip64local_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ |
@@ -1737,7 +1742,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s | |||
1737 | if (err==ZIP_OK) | 1742 | if (err==ZIP_OK) |
1738 | err = add_data_in_datablock(&zi->central_dir, zi->ci.central_header, (uLong)zi->ci.size_centralheader); | 1743 | err = add_data_in_datablock(&zi->central_dir, zi->ci.central_header, (uLong)zi->ci.size_centralheader); |
1739 | 1744 | ||
1740 | free(zi->ci.central_header); | 1745 | TRYFREE(zi->ci.central_header); |
1741 | 1746 | ||
1742 | if (err==ZIP_OK) | 1747 | if (err==ZIP_OK) |
1743 | { | 1748 | { |
@@ -1849,7 +1854,7 @@ int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centra | |||
1849 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2); | 1854 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2); |
1850 | 1855 | ||
1851 | if (err==ZIP_OK) /* version needed */ | 1856 | if (err==ZIP_OK) /* version needed */ |
1852 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2); | 1857 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)((zi->ci.flag & ZIP_ENCODING_UTF8) ? 63 : 45),2); |
1853 | 1858 | ||
1854 | if (err==ZIP_OK) /* number of this disk */ | 1859 | if (err==ZIP_OK) /* number of this disk */ |
1855 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); | 1860 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); |
@@ -2031,6 +2036,9 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe | |||
2031 | return ZIP_PARAMERROR; | 2036 | return ZIP_PARAMERROR; |
2032 | 2037 | ||
2033 | pNewHeader = (char*)ALLOC(*dataLen); | 2038 | pNewHeader = (char*)ALLOC(*dataLen); |
2039 | if(!pNewHeader) { | ||
2040 | return Z_MEM_ERROR; | ||
2041 | } | ||
2034 | pTmp = pNewHeader; | 2042 | pTmp = pNewHeader; |
2035 | 2043 | ||
2036 | while(p < (pData + *dataLen)) | 2044 | while(p < (pData + *dataLen)) |
diff --git a/rbutil/rbutilqt/quazip/zip.h b/rbutil/rbutilqt/quazip/zip.h index a6617add0f..114a1bf6e7 100644 --- a/rbutil/rbutilqt/quazip/zip.h +++ b/rbutil/rbutilqt/quazip/zip.h | |||
@@ -53,7 +53,7 @@ extern "C" { | |||
53 | //#define HAVE_BZIP2 | 53 | //#define HAVE_BZIP2 |
54 | 54 | ||
55 | #ifndef _ZLIB_H | 55 | #ifndef _ZLIB_H |
56 | #include "zlib.h" | 56 | #include <zlib.h> |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | #ifndef _ZLIBIOAPI_H | 59 | #ifndef _ZLIBIOAPI_H |
@@ -85,6 +85,7 @@ typedef voidp zipFile; | |||
85 | #define ZIP_WRITE_DATA_DESCRIPTOR 0x8u | 85 | #define ZIP_WRITE_DATA_DESCRIPTOR 0x8u |
86 | #define ZIP_AUTO_CLOSE 0x1u | 86 | #define ZIP_AUTO_CLOSE 0x1u |
87 | #define ZIP_SEQUENTIAL 0x2u | 87 | #define ZIP_SEQUENTIAL 0x2u |
88 | #define ZIP_ENCODING_UTF8 0x0800u | ||
88 | #define ZIP_DEFAULT_FLAGS (ZIP_AUTO_CLOSE | ZIP_WRITE_DATA_DESCRIPTOR) | 89 | #define ZIP_DEFAULT_FLAGS (ZIP_AUTO_CLOSE | ZIP_WRITE_DATA_DESCRIPTOR) |
89 | 90 | ||
90 | #ifndef DEF_MEM_LEVEL | 91 | #ifndef DEF_MEM_LEVEL |