diff options
Diffstat (limited to 'rbutil/rbutilqt/zip/unzip.h')
-rw-r--r-- | rbutil/rbutilqt/zip/unzip.h | 288 |
1 files changed, 144 insertions, 144 deletions
diff --git a/rbutil/rbutilqt/zip/unzip.h b/rbutil/rbutilqt/zip/unzip.h index a48fbe8724..e480541716 100644 --- a/rbutil/rbutilqt/zip/unzip.h +++ b/rbutil/rbutilqt/zip/unzip.h | |||
@@ -1,144 +1,144 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Filename: unzip.h | 2 | ** Filename: unzip.h |
3 | ** Last updated [dd/mm/yyyy]: 28/01/2007 | 3 | ** Last updated [dd/mm/yyyy]: 28/01/2007 |
4 | ** | 4 | ** |
5 | ** pkzip 2.0 decompression. | 5 | ** pkzip 2.0 decompression. |
6 | ** | 6 | ** |
7 | ** Some of the code has been inspired by other open source projects, | 7 | ** Some of the code has been inspired by other open source projects, |
8 | ** (mainly Info-Zip and Gilles Vollant's minizip). | 8 | ** (mainly Info-Zip and Gilles Vollant's minizip). |
9 | ** Compression and decompression actually uses the zlib library. | 9 | ** Compression and decompression actually uses the zlib library. |
10 | ** | 10 | ** |
11 | ** Copyright (C) 2007 Angius Fabrizio. All rights reserved. | 11 | ** Copyright (C) 2007 Angius Fabrizio. All rights reserved. |
12 | ** | 12 | ** |
13 | ** This file is part of the OSDaB project (http://osdab.sourceforge.net/). | 13 | ** This file is part of the OSDaB project (http://osdab.sourceforge.net/). |
14 | ** | 14 | ** |
15 | ** This file may be distributed and/or modified under the terms of the | 15 | ** This file may be distributed and/or modified under the terms of the |
16 | ** GNU General Public License version 2 as published by the Free Software | 16 | ** GNU General Public License version 2 as published by the Free Software |
17 | ** Foundation and appearing in the file LICENSE.GPL included in the | 17 | ** Foundation and appearing in the file LICENSE.GPL included in the |
18 | ** packaging of this file. | 18 | ** packaging of this file. |
19 | ** | 19 | ** |
20 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 20 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
21 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 21 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
22 | ** | 22 | ** |
23 | ** See the file LICENSE.GPL that came with this software distribution or | 23 | ** See the file LICENSE.GPL that came with this software distribution or |
24 | ** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information. | 24 | ** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information. |
25 | ** | 25 | ** |
26 | **********************************************************************/ | 26 | **********************************************************************/ |
27 | 27 | ||
28 | #ifndef OSDAB_UNZIP__H | 28 | #ifndef OSDAB_UNZIP__H |
29 | #define OSDAB_UNZIP__H | 29 | #define OSDAB_UNZIP__H |
30 | 30 | ||
31 | #include <QtGlobal> | 31 | #include <QtGlobal> |
32 | #include <QMap> | 32 | #include <QMap> |
33 | #include <QDateTime> | 33 | #include <QDateTime> |
34 | 34 | ||
35 | #include <zlib/zlib.h> | 35 | #include <zlib/zlib.h> |
36 | 36 | ||
37 | class UnzipPrivate; | 37 | class UnzipPrivate; |
38 | class QIODevice; | 38 | class QIODevice; |
39 | class QFile; | 39 | class QFile; |
40 | class QDir; | 40 | class QDir; |
41 | class QStringList; | 41 | class QStringList; |
42 | class QString; | 42 | class QString; |
43 | 43 | ||
44 | 44 | ||
45 | class UnZip | 45 | class UnZip |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | enum ErrorCode | 48 | enum ErrorCode |
49 | { | 49 | { |
50 | Ok, | 50 | Ok, |
51 | ZlibInit, | 51 | ZlibInit, |
52 | ZlibError, | 52 | ZlibError, |
53 | OpenFailed, | 53 | OpenFailed, |
54 | PartiallyCorrupted, | 54 | PartiallyCorrupted, |
55 | Corrupted, | 55 | Corrupted, |
56 | WrongPassword, | 56 | WrongPassword, |
57 | NoOpenArchive, | 57 | NoOpenArchive, |
58 | FileNotFound, | 58 | FileNotFound, |
59 | ReadFailed, | 59 | ReadFailed, |
60 | WriteFailed, | 60 | WriteFailed, |
61 | SeekFailed, | 61 | SeekFailed, |
62 | CreateDirFailed, | 62 | CreateDirFailed, |
63 | InvalidDevice, | 63 | InvalidDevice, |
64 | InvalidArchive, | 64 | InvalidArchive, |
65 | HeaderConsistencyError, | 65 | HeaderConsistencyError, |
66 | 66 | ||
67 | Skip, SkipAll // internal use only | 67 | Skip, SkipAll // internal use only |
68 | }; | 68 | }; |
69 | 69 | ||
70 | enum ExtractionOption | 70 | enum ExtractionOption |
71 | { | 71 | { |
72 | //! Extracts paths (default) | 72 | //! Extracts paths (default) |
73 | ExtractPaths = 0x0001, | 73 | ExtractPaths = 0x0001, |
74 | //! Ignores paths and extracts all the files to the same directory | 74 | //! Ignores paths and extracts all the files to the same directory |
75 | SkipPaths = 0x0002 | 75 | SkipPaths = 0x0002 |
76 | }; | 76 | }; |
77 | Q_DECLARE_FLAGS(ExtractionOptions, ExtractionOption) | 77 | Q_DECLARE_FLAGS(ExtractionOptions, ExtractionOption) |
78 | 78 | ||
79 | enum CompressionMethod | 79 | enum CompressionMethod |
80 | { | 80 | { |
81 | NoCompression, Deflated, UnknownCompression | 81 | NoCompression, Deflated, UnknownCompression |
82 | }; | 82 | }; |
83 | 83 | ||
84 | enum FileType | 84 | enum FileType |
85 | { | 85 | { |
86 | File, Directory | 86 | File, Directory |
87 | }; | 87 | }; |
88 | 88 | ||
89 | typedef struct ZipEntry | 89 | typedef struct ZipEntry |
90 | { | 90 | { |
91 | ZipEntry(); | 91 | ZipEntry(); |
92 | 92 | ||
93 | QString filename; | 93 | QString filename; |
94 | QString comment; | 94 | QString comment; |
95 | 95 | ||
96 | quint32 compressedSize; | 96 | quint32 compressedSize; |
97 | quint32 uncompressedSize; | 97 | quint32 uncompressedSize; |
98 | quint32 crc32; | 98 | quint32 crc32; |
99 | 99 | ||
100 | QDateTime lastModified; | 100 | QDateTime lastModified; |
101 | 101 | ||
102 | CompressionMethod compression; | 102 | CompressionMethod compression; |
103 | FileType type; | 103 | FileType type; |
104 | 104 | ||
105 | bool encrypted; | 105 | bool encrypted; |
106 | }; | 106 | }; |
107 | 107 | ||
108 | UnZip(); | 108 | UnZip(); |
109 | virtual ~UnZip(); | 109 | virtual ~UnZip(); |
110 | 110 | ||
111 | bool isOpen() const; | 111 | bool isOpen() const; |
112 | 112 | ||
113 | ErrorCode openArchive(const QString& filename); | 113 | ErrorCode openArchive(const QString& filename); |
114 | ErrorCode openArchive(QIODevice* device); | 114 | ErrorCode openArchive(QIODevice* device); |
115 | void closeArchive(); | 115 | void closeArchive(); |
116 | 116 | ||
117 | QString archiveComment() const; | 117 | QString archiveComment() const; |
118 | 118 | ||
119 | QString formatError(UnZip::ErrorCode c) const; | 119 | QString formatError(UnZip::ErrorCode c) const; |
120 | 120 | ||
121 | bool contains(const QString& file) const; | 121 | bool contains(const QString& file) const; |
122 | 122 | ||
123 | QStringList fileList() const; | 123 | QStringList fileList() const; |
124 | QList<ZipEntry> entryList() const; | 124 | QList<ZipEntry> entryList() const; |
125 | 125 | ||
126 | ErrorCode extractAll(const QString& dirname, ExtractionOptions options = ExtractPaths); | 126 | ErrorCode extractAll(const QString& dirname, ExtractionOptions options = ExtractPaths); |
127 | ErrorCode extractAll(const QDir& dir, ExtractionOptions options = ExtractPaths); | 127 | ErrorCode extractAll(const QDir& dir, ExtractionOptions options = ExtractPaths); |
128 | 128 | ||
129 | ErrorCode extractFile(const QString& filename, const QString& dirname, ExtractionOptions options = ExtractPaths); | 129 | ErrorCode extractFile(const QString& filename, const QString& dirname, ExtractionOptions options = ExtractPaths); |
130 | ErrorCode extractFile(const QString& filename, const QDir& dir, ExtractionOptions options = ExtractPaths); | 130 | ErrorCode extractFile(const QString& filename, const QDir& dir, ExtractionOptions options = ExtractPaths); |
131 | ErrorCode extractFile(const QString& filename, QIODevice* device, ExtractionOptions options = ExtractPaths); | 131 | ErrorCode extractFile(const QString& filename, QIODevice* device, ExtractionOptions options = ExtractPaths); |
132 | 132 | ||
133 | ErrorCode extractFiles(const QStringList& filenames, const QString& dirname, ExtractionOptions options = ExtractPaths); | 133 | ErrorCode extractFiles(const QStringList& filenames, const QString& dirname, ExtractionOptions options = ExtractPaths); |
134 | ErrorCode extractFiles(const QStringList& filenames, const QDir& dir, ExtractionOptions options = ExtractPaths); | 134 | ErrorCode extractFiles(const QStringList& filenames, const QDir& dir, ExtractionOptions options = ExtractPaths); |
135 | 135 | ||
136 | void setPassword(const QString& pwd); | 136 | void setPassword(const QString& pwd); |
137 | 137 | ||
138 | private: | 138 | private: |
139 | UnzipPrivate* d; | 139 | UnzipPrivate* d; |
140 | }; | 140 | }; |
141 | 141 | ||
142 | Q_DECLARE_OPERATORS_FOR_FLAGS(UnZip::ExtractionOptions) | 142 | Q_DECLARE_OPERATORS_FOR_FLAGS(UnZip::ExtractionOptions) |
143 | 143 | ||
144 | #endif // OSDAB_UNZIP__H | 144 | #endif // OSDAB_UNZIP__H |