1 | /* This file is part of the KDE libraries |
2 | SPDX-FileCopyrightText: 2007-2008 Per Øyvind Karlsen <peroyvind@mandriva.org> |
3 | |
4 | Based on kbzip2filter: |
5 | SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org> |
6 | |
7 | SPDX-License-Identifier: LGPL-2.0-or-later |
8 | */ |
9 | |
10 | #ifndef KXZFILTER_H |
11 | #define KXZFILTER_H |
12 | |
13 | #include <config-compression.h> |
14 | |
15 | #if HAVE_XZ_SUPPORT |
16 | |
17 | #include "kfilterbase.h" |
18 | |
19 | /** |
20 | * Internal class used by KCompressionDevice |
21 | * @internal |
22 | */ |
23 | class KXzFilter : public KFilterBase |
24 | { |
25 | public: |
26 | KXzFilter(); |
27 | ~KXzFilter() override; |
28 | |
29 | bool init(int) override; |
30 | |
31 | enum Flag { |
32 | AUTO = 0, |
33 | LZMA = 1, |
34 | LZMA2 = 2, |
35 | BCJ = 3, // X86 |
36 | POWERPC = 4, |
37 | IA64 = 5, |
38 | ARM = 6, |
39 | ARMTHUMB = 7, |
40 | SPARC = 8, |
41 | }; |
42 | |
43 | virtual bool init(int, Flag flag, const QList<unsigned char> &props); |
44 | int mode() const override; |
45 | bool terminate() override; |
46 | void reset() override; |
47 | bool () override |
48 | { |
49 | return true; // lzma handles it by itself ! Cool ! |
50 | } |
51 | bool (const QByteArray &) override |
52 | { |
53 | return true; |
54 | } |
55 | void setOutBuffer(char *data, uint maxlen) override; |
56 | void setInBuffer(const char *data, uint size) override; |
57 | int inBufferAvailable() const override; |
58 | int outBufferAvailable() const override; |
59 | Result uncompress() override; |
60 | Result compress(bool finish) override; |
61 | |
62 | private: |
63 | class Private; |
64 | Private *const d; |
65 | }; |
66 | |
67 | #endif |
68 | |
69 | #endif // KXZFILTER_H |
70 | |