quickmod/FuseMounter/fusebase.h
Daniel O'Neill 191cd5362a Lots of fixes, VFS now seems to work reliably. Still a lot of cleanup and shoring to do.
Decided to leave the VFS tab for now. Filtering likely doesn't work, except Show Only Open. Sorting works.
Rewrites to replace dynamicRoles done for Mods and Plugins tables.
Database.qml now reads "moddir", though installing extracted is still unimplemented so far.
Launch still doesn't work.
Ignore the "file -> test extract". It's a test for file extraction.
2025-11-10 13:15:26 -08:00

74 lines
2.5 KiB
C++

#ifndef FUSEBASE_H
#define FUSEBASE_H
#include <QFileDevice>
#include <QMap>
#include <QObject>
#include <QString>
class FuseInterface;
class FuseAccessorBase;
class FuseFHBase;
class FuseAccessorBase : public QObject
{
Q_OBJECT
public:
typedef enum { FH_UNKNOWN=1, FH_ARCHIVE=2, FH_PROXY=3, FH_SANDBOX=4 } e_fh_type;
protected:
FuseInterface *m_parent;
bool m_stopping;
QString m_resource;
e_fh_type m_type;
Q_ENUM(e_fh_type)
public:
explicit FuseAccessorBase(FuseInterface *parent, const QString &resource, e_fh_type type=FH_UNKNOWN);
virtual ~FuseAccessorBase();
e_fh_type getType() { return m_type; }
const QString &getResource() { return m_resource; }
FuseInterface *getInterface() { return m_parent; }
virtual int getattr(const QString &path, struct stat *stbuf) = 0;
virtual QStringList readdir(const QString &path) = 0;
virtual FuseFHBase *open(const QString &path, QIODeviceBase::OpenMode mode) = 0;
virtual int truncate(const QString &path, off_t offset) { Q_UNUSED(path) Q_UNUSED(offset) return -1; }
virtual int rename(const QString &path, const QString &newname) { Q_UNUSED(path) Q_UNUSED(newname) return -1; }
virtual int rmdir(const QString &path) { Q_UNUSED(path) return -1; }
virtual int unlink(const QString &path) { Q_UNUSED(path) return -1; }
virtual int mkdir(const QString &path, QFileDevice::Permissions mode) { Q_UNUSED(path) Q_UNUSED(mode) return -1; }
virtual int create(const QString &path, QFileDevice::Permissions mode) { Q_UNUSED(path) Q_UNUSED(mode) return -1; }
};
class FuseFHBase : public QObject
{
Q_OBJECT
protected:
friend class FuseInterface;
FuseAccessorBase *m_parent;
QString m_path;
QIODeviceBase::OpenMode m_mode;
public:
explicit FuseFHBase(FuseAccessorBase *parent, const QString &path);
virtual ~FuseFHBase() {}
FuseAccessorBase *getAccessor() { return m_parent; }
virtual const QString getResource() { return m_parent->getResource(); }
const QString &getPath() { return m_path; }
virtual bool open(QIODeviceBase::OpenMode mode) = 0;
virtual QByteArray read(size_t size, off_t offset) = 0;
virtual off_t lseek(off_t off, int whence) = 0;
virtual int write(const QByteArray &data, off_t offset, struct fuse_file_info *fi) { Q_UNUSED(data) Q_UNUSED(offset) Q_UNUSED(fi) return -1; }
virtual void release() {}
};
#endif // FUSEBASE_H