1 /****************************************************************************
3 ** Last updated [dd/mm/yyyy]: 01/02/2007
5 ** pkzip 2.0 file compression.
7 ** Some of the code has been inspired by other open source projects,
8 ** (mainly Info-Zip and Gilles Vollant's minizip).
9 ** Compression and decompression actually uses the zlib library.
11 ** Copyright (C) 2007 Angius Fabrizio. All rights reserved.
13 ** This file is part of the OSDaB project (http://osdab.sourceforge.net/).
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
17 ** Foundation and appearing in the file LICENSE.GPL included in the
18 ** packaging of this file.
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.
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.
26 **********************************************************************/
34 #include <zlib/zlib.h>
65 Deflate1
= 1, Deflate2
, Deflate3
, Deflate4
,
66 Deflate5
, Deflate6
, Deflate7
, Deflate8
, Deflate9
,
67 AutoCPU
, AutoMIME
, AutoFull
70 enum CompressionOption
72 //! Does not preserve absolute paths in the zip file when adding a file/directory (default)
73 RelativePaths
= 0x0001,
74 //! Preserve absolute paths
75 AbsolutePaths
= 0x0002,
76 //! Do not store paths. All the files are put in the (evtl. user defined) root of the zip file
79 Q_DECLARE_FLAGS(CompressionOptions
, CompressionOption
)
86 void setPassword(const QString
& pwd
);
88 QString
password() const;
90 ErrorCode
createArchive(const QString
& file
, bool overwrite
= true);
91 ErrorCode
createArchive(QIODevice
* device
);
93 QString
archiveComment() const;
94 void setArchiveComment(const QString
& comment
);
96 ErrorCode
addDirectoryContents(const QString
& path
, CompressionLevel level
= AutoFull
);
97 ErrorCode
addDirectoryContents(const QString
& path
, const QString
& root
, CompressionLevel level
= AutoFull
);
99 ErrorCode
addDirectory(const QString
& path
, CompressionOptions options
= RelativePaths
, CompressionLevel level
= AutoFull
);
100 ErrorCode
addDirectory(const QString
& path
, const QString
& root
, CompressionLevel level
= AutoFull
);
101 ErrorCode
addDirectory(const QString
& path
, const QString
& root
, CompressionOptions options
= RelativePaths
, CompressionLevel level
= AutoFull
);
103 ErrorCode
closeArchive();
105 QString
formatError(ErrorCode c
) const;
107 virtual void progress() {}
113 Q_DECLARE_OPERATORS_FOR_FLAGS(Zip::CompressionOptions
)
115 #endif // OSDAB_ZIP__H