File indexing completed on 2024-04-28 11:33:48

0001 /* This file is part of the KDE libraries
0002    SPDX-FileCopyrightText: 2007-2008 Per Øyvind Karlsen <peroyvind@mandriva.org>
0003 
0004    Based on kbzip2filter:
0005    SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org>
0006 
0007    SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 #ifndef KXZFILTER_H
0011 #define KXZFILTER_H
0012 
0013 #include <config-compression.h>
0014 
0015 #if HAVE_XZ_SUPPORT
0016 
0017 #include "kfilterbase.h"
0018 
0019 /**
0020  * Internal class used by KCompressionDevice
0021  * @internal
0022  */
0023 class KXzFilter : public KFilterBase
0024 {
0025 public:
0026     KXzFilter();
0027     ~KXzFilter() override;
0028 
0029     bool init(int) override;
0030 
0031     enum Flag {
0032         AUTO = 0,
0033         LZMA = 1,
0034         LZMA2 = 2,
0035         BCJ = 3, // X86
0036         POWERPC = 4,
0037         IA64 = 5,
0038         ARM = 6,
0039         ARMTHUMB = 7,
0040         SPARC = 8,
0041     };
0042 
0043     virtual bool init(int, Flag flag, const QVector<unsigned char> &props);
0044     int mode() const override;
0045     bool terminate() override;
0046     void reset() override;
0047     bool readHeader() override
0048     {
0049         return true; // lzma handles it by itself ! Cool !
0050     }
0051     bool writeHeader(const QByteArray &) override
0052     {
0053         return true;
0054     }
0055     void setOutBuffer(char *data, uint maxlen) override;
0056     void setInBuffer(const char *data, uint size) override;
0057     int inBufferAvailable() const override;
0058     int outBufferAvailable() const override;
0059     Result uncompress() override;
0060     Result compress(bool finish) override;
0061 
0062 private:
0063     class Private;
0064     Private *const d;
0065 };
0066 
0067 #endif
0068 
0069 #endif // KXZFILTER_H