File indexing completed on 2024-05-26 16:15:29

0001 /* This file is part of the KDE project
0002    Copyright (C) 2002 David Faure <faure@kde.org>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef koTarStore_h
0021 #define koTarStore_h
0022 
0023 #include "KoStore.h"
0024 
0025 #include <QByteArray>
0026 
0027 class KTar;
0028 class KArchiveDirectory;
0029 class QUrl;
0030 
0031 class KoTarStore : public KoStore
0032 {
0033 public:
0034     KoTarStore(const QString & _filename, Mode _mode, const QByteArray & appIdentification,
0035                bool writeMimetype);
0036     KoTarStore(QIODevice *dev, Mode mode, const QByteArray & appIdentification,
0037                bool writeMimetype);
0038     /**
0039      * QUrl-constructor
0040      * @todo saving not completely implemented (fixed temporary file)
0041      */
0042     KoTarStore(QWidget* window, const QUrl &url, const QString & _filename, Mode _mode,
0043                const QByteArray & appIdentification, bool writeMimetype = true);
0044     ~KoTarStore() override;
0045 
0046     QStringList directoryList() const override;
0047 
0048 protected:
0049     void init(const QByteArray &appIdentification);
0050     bool doFinalize() override;
0051     bool openWrite(const QString& name) override;
0052     bool openRead(const QString& name) override;
0053     bool closeWrite() override;
0054     bool closeRead() override {
0055         return true;
0056     }
0057     bool enterRelativeDirectory(const QString& dirName) override;
0058     bool enterAbsoluteDirectory(const QString& path) override;
0059     bool fileExists(const QString& absPath) const override;
0060 
0061     static QByteArray completeMagic(const QByteArray& appMimetype);
0062 
0063     /// The tar archive
0064     KTar * m_pTar;
0065 
0066     /** In "Read" mode this pointer is pointing to the
0067     current directory in the archive to speed up the verification process */
0068     const KArchiveDirectory* m_currentDir;
0069 
0070     /// Buffer used when writing
0071     QByteArray m_byteArray;
0072 private:
0073     Q_DECLARE_PRIVATE(KoStore)
0074 };
0075 
0076 #endif