67 lines
1.9 KiB
C++
67 lines
1.9 KiB
C++
#ifndef FUSEPROXY_H
|
|
#define FUSEPROXY_H
|
|
|
|
#include <QFile>
|
|
#include <QList>
|
|
#include <QObject>
|
|
#include <QSqlDatabase>
|
|
#include <QString>
|
|
|
|
#include "fusebase.h"
|
|
|
|
typedef struct {
|
|
int modId;
|
|
int fileId;
|
|
QString basedir;
|
|
|
|
QString actual;
|
|
QString mapped;
|
|
QString lmapped;
|
|
QStringList lparts;
|
|
} FuseProxyMapping;
|
|
|
|
class FuseAccessorProxy : public FuseAccessorBase
|
|
{
|
|
Q_OBJECT
|
|
|
|
QList< FuseProxyMapping > m_entries;
|
|
|
|
public:
|
|
explicit FuseAccessorProxy(FuseInterface *parent, const QString &resource, e_fh_type type=FH_PROXY);
|
|
explicit FuseAccessorProxy(FuseInterface *parent, QList< FuseProxyMapping > entries);
|
|
virtual ~FuseAccessorProxy();
|
|
|
|
int getattr(const QString &path, struct stat *stbuf) override;
|
|
QStringList readdir(const QString &path) override;
|
|
FuseFHBase *open(const QString &path, QIODeviceBase::OpenMode mode) override;
|
|
|
|
QString fullPath(const QString &path);
|
|
QString resolvePath(const QString &root, const QString &path, bool justPath=false);
|
|
|
|
static QList<FuseProxyMapping> proxyList(QSqlDatabase &database, int profileId);
|
|
|
|
// This expects the new entry to be created, then return "write" on the opened handle, otherwise return the appropriate "write" error code.
|
|
int makeWritable(struct fuse_file_info *fi, const QString &path, QIODeviceBase::OpenMode mode, const QByteArray &data, off_t offset);
|
|
};
|
|
|
|
|
|
class FuseFHProxy : public FuseFHBase
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit FuseFHProxy(FuseAccessorProxy *parent, const QString &path, const QString &newpath);
|
|
virtual ~FuseFHProxy();
|
|
|
|
bool open(QIODeviceBase::OpenMode mode) override;
|
|
QByteArray read(size_t size, off_t offset) override;
|
|
off_t lseek(off_t off, int whence) override;
|
|
|
|
int write(const QByteArray &data, off_t offset, fuse_file_info *fi) override;
|
|
void release() override;
|
|
|
|
QFile m_file;
|
|
};
|
|
|
|
|
|
#endif // FUSEPROXY_H
|