File indexing completed on 2024-04-28 08:49:47

0001 /*  This file is part of the KDE libraries
0002     SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KIO_ARCHIVEBASE_H
0008 #define KIO_ARCHIVEBASE_H
0009 
0010 #include <sys/types.h>
0011 
0012 #include <KIO/Global>
0013 #include <KIO/WorkerBase>
0014 
0015 #include "libkioarchive_export.h"
0016 
0017 class KArchive;
0018 class KArchiveEntry;
0019 class KArchiveDirectory;
0020 
0021 class LIBKIOARCHIVE_EXPORT ArchiveProtocolBase : public KIO::WorkerBase
0022 {
0023 public:
0024     ArchiveProtocolBase(const QByteArray &proto, const QByteArray &pool, const QByteArray &app);
0025     ~ArchiveProtocolBase() override;
0026 
0027     KIO::WorkerResult listDir(const QUrl &url) override;
0028     KIO::WorkerResult stat(const QUrl &url) override;
0029     KIO::WorkerResult get(const QUrl &url) override;
0030 
0031 private:
0032     void createRootUDSEntry(KIO::UDSEntry &entry);
0033     void createUDSEntry(const KArchiveEntry *tarEntry, KIO::UDSEntry &entry);
0034 
0035     virtual KArchive *createArchive(const QString &proto, const QString &archiveFile) = 0;
0036 
0037     KIO::StatDetails getStatDetails();
0038     uint computeArchiveDirSize(const KArchiveDirectory *dir);
0039 
0040     /**
0041      * \brief find, check and open the archive file
0042      * \param url The URL of the archive
0043      * \param path Path where the archive really is (returned value)
0044      * \param errNum KIO error number (undefined if the function returns true)
0045      * \return true if file was found, false if there was an error
0046      */
0047     bool checkNewFile(const QUrl &url, QString &path, KIO::Error &errorNum);
0048 
0049     KArchive *m_archiveFile;
0050     QString m_archiveName;
0051     QString m_user, m_group;
0052     time_t m_mtime;
0053 };
0054 
0055 #endif // KIO_ARCHIVEBASE_H