1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#ifndef QZIPWRITER_H
4#define QZIPWRITER_H
5
6#include <QtCore/private/qglobal_p.h>
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of the QZipWriter class. This header file may change from
14// version to version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/qstring.h>
20#include <QtCore/qfile.h>
21
22QT_BEGIN_NAMESPACE
23
24class QZipWriterPrivate;
25
26class Q_CORE_EXPORT QZipWriter
27{
28public:
29 explicit QZipWriter(const QString &fileName, QIODevice::OpenMode mode = (QIODevice::WriteOnly | QIODevice::Truncate) );
30
31 explicit QZipWriter(QIODevice *device);
32 ~QZipWriter();
33
34 QIODevice* device() const;
35
36 bool isWritable() const;
37 bool exists() const;
38
39 enum Status {
40 NoError,
41 FileWriteError,
42 FileOpenError,
43 FilePermissionsError,
44 FileError
45 };
46
47 Status status() const;
48
49 enum CompressionPolicy {
50 AlwaysCompress,
51 NeverCompress,
52 AutoCompress
53 };
54
55 void setCompressionPolicy(CompressionPolicy policy);
56 CompressionPolicy compressionPolicy() const;
57
58 void setCreationPermissions(QFile::Permissions permissions);
59 QFile::Permissions creationPermissions() const;
60
61 void addFile(const QString &fileName, const QByteArray &data);
62
63 void addFile(const QString &fileName, QIODevice *device);
64
65 void addDirectory(const QString &dirName);
66
67 void addSymLink(const QString &fileName, const QString &destination);
68
69 void close();
70private:
71 QZipWriterPrivate *d;
72 Q_DISABLE_COPY_MOVE(QZipWriter)
73};
74
75QT_END_NAMESPACE
76
77#endif // QZIPWRITER_H
78

source code of qtbase/src/corelib/io/qzipwriter_p.h