Sandboxie/SandboxiePlus/MiscHelpers/Archive/ArchiveFS.h

91 lines
2.6 KiB
C
Raw Normal View History

2022-11-12 09:45:35 +00:00
#pragma once
#include <private/qabstractfileengine_p.h>
#include "Archive.h"
#include "../mischelpers_global.h"
//////////////////////////////////////////////////////////////////////////////////////////
// C7zFileEngine
//
class MISCHELPERS_EXPORT C7zFileEngine : public QAbstractFileEngine
{
protected:
friend class C7zFileEngineHandler;
C7zFileEngine(const QString& filename, CArchive* pArchive, QMutex* pMutex);
public:
virtual ~C7zFileEngine();
2023-04-22 14:07:37 +01:00
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
2022-11-12 09:45:35 +00:00
virtual bool open(QIODevice::OpenMode openMode);
2023-04-22 14:07:37 +01:00
#else
virtual bool open(QIODevice::OpenMode openMode, std::optional<QFile::Permissions> permissions);
#endif
2022-11-12 09:45:35 +00:00
virtual bool close();
virtual bool flush();
virtual qint64 size() const;
virtual qint64 pos() const;
virtual bool seek(qint64 pos);
virtual bool isSequential() const;
virtual bool remove();
virtual bool mkdir(const QString& dirName, bool createParentDirectories) const;
virtual bool rmdir(const QString& dirName, bool recurseParentDirectories) const;
virtual bool caseSensitive() const;
virtual bool isRelativePath() const;
virtual FileFlags fileFlags(FileFlags type = FileInfoAll) const;
virtual QString fileName(FileName file = DefaultName) const;
virtual QDateTime fileTime(FileTime time) const;
virtual void setFileName(const QString& file);
bool atEnd() const;
virtual qint64 read(char* data, qint64 maxlen);
virtual qint64 readLine(char* data, qint64 maxlen);
virtual qint64 write(const char* data, qint64 len);
bool isOpened() const;
QAbstractFileEngine::Iterator* beginEntryList(QDir::Filters filters, const QStringList& filterNames);
QFile::FileError error() const;
QString errorString() const;
virtual bool supportsExtension(Extension extension) const;
private:
qint64 _size;
FileFlags _flags;
QString _filename;
QDateTime _datetime;
int _index;
QByteArray _data;
qint64 _pos;
CArchive* _pArchive;
QMutex* _pMutex;
};
//////////////////////////////////////////////////////////////////////////////////////////
// C7zFileEngineHandler
//
class MISCHELPERS_EXPORT C7zFileEngineHandler : public QObject, public QAbstractFileEngineHandler
{
public:
2023-07-01 17:54:53 +01:00
C7zFileEngineHandler(const QString& Scheme, QObject* parent = NULL);
2022-11-12 09:45:35 +00:00
~C7zFileEngineHandler();
2023-07-01 17:54:53 +01:00
bool Open(const QString& ArchivePath);
void Close();
2022-11-12 09:45:35 +00:00
bool IsOpen() { return m_pArchive != NULL; }
QString Prefix() { return m_Scheme; }
QAbstractFileEngine* create(const QString& filename) const;
private:
QString m_Scheme;
CArchive* m_pArchive;
mutable QMutex m_Mutex;
};