1/* This file is part of the KDE libraries
2 SPDX-FileCopyrightText: 2014 David Faure <faure@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6#ifndef KRCC_H
7#define KRCC_H
8
9#include <karchive.h>
10
11/**
12 * KRcc is a class for reading dynamic binary resources created by Qt's rcc tool
13 * from a .qrc file and the files it points to.
14 *
15 * Writing is not supported.
16 * @short A class for reading rcc resources.
17 * @since 5.3
18 */
19class KARCHIVE_EXPORT KRcc : public KArchive
20{
21 Q_DECLARE_TR_FUNCTIONS(KRcc)
22
23public:
24 /**
25 * Creates an instance that operates on the given filename.
26 *
27 * @param filename is a local path (e.g. "/home/holger/myfile.rcc")
28 */
29 explicit KRcc(const QString &filename);
30
31 /**
32 * If the rcc file is still opened, then it will be
33 * closed automatically by the destructor.
34 */
35 ~KRcc() override;
36
37protected:
38 /*
39 * Writing is not supported by this class, will always fail.
40 * @return always false
41 */
42 bool doPrepareWriting(const QString &name,
43 const QString &user,
44 const QString &group,
45 qint64 size,
46 mode_t perm,
47 const QDateTime &atime,
48 const QDateTime &mtime,
49 const QDateTime &ctime) override;
50
51 /*
52 * Writing is not supported by this class, will always fail.
53 * @return always false
54 */
55 bool doFinishWriting(qint64 size) override;
56
57 /*
58 * Writing is not supported by this class, will always fail.
59 * @return always false
60 */
61 bool doWriteDir(const QString &name,
62 const QString &user,
63 const QString &group,
64 mode_t perm,
65 const QDateTime &atime,
66 const QDateTime &mtime,
67 const QDateTime &ctime) override;
68
69 /*
70 * Writing is not supported by this class, will always fail.
71 * @return always false
72 */
73 bool doWriteSymLink(const QString &name,
74 const QString &target,
75 const QString &user,
76 const QString &group,
77 mode_t perm,
78 const QDateTime &atime,
79 const QDateTime &mtime,
80 const QDateTime &ctime) override;
81
82 /**
83 * Registers the .rcc resource in the QResource system under a unique identifier,
84 * then lists that, and creates the KArchiveFile/KArchiveDirectory entries.
85 */
86 bool openArchive(QIODevice::OpenMode mode) override;
87 /**
88 * Unregisters the .rcc resource from the QResource system.
89 */
90 bool closeArchive() override;
91
92protected:
93 void virtual_hook(int id, void *data) override;
94
95private:
96 class KRccPrivate;
97 KRccPrivate *const d;
98};
99
100#endif
101

source code of karchive/src/krcc.h