QTfrontend/util/FileEngine.h
author unc0rr
Sat, 20 Oct 2012 00:20:39 +0400
branchphysfslayer
changeset 7768 13e2037ebc79
child 7770 ff3442338882
permissions -rw-r--r--
Try using PhysicsFS. First step: break frontend.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     1
#ifndef _FileEngine_h
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     2
#define _FileEngine_h
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     3
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     4
#include <QAbstractFileEngine>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     5
#include <QAbstractFileEngineHandler>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     6
#include <QDateTime>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     7
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     8
#include "physfs.h"
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     9
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    10
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    11
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    12
class FileEngine : public QAbstractFileEngine
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    13
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    14
    public:
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    15
        FileEngine(const QString& filename);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    16
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    17
        virtual ~FileEngine();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    18
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    19
        virtual bool open(QIODevice::OpenMode openMode);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    20
        virtual bool close();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    21
        virtual bool flush();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    22
        virtual qint64 size() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    23
        virtual qint64 pos() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    24
        virtual bool seek(qint64 pos);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    25
        virtual bool isSequential() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    26
        virtual bool remove();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    27
        virtual bool mkdir(const QString &dirName, bool createParentDirectories) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    28
        virtual bool rmdir(const QString &dirName, bool recurseParentDirectories) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    29
        virtual bool caseSensitive() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    30
        virtual bool isRelativePath() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    31
        virtual QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    32
        virtual FileFlags fileFlags(FileFlags type=FileInfoAll) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    33
        virtual QString fileName(FileName file=DefaultName) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    34
        virtual QDateTime fileTime(FileTime time) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    35
        virtual void setFileName(const QString &file);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    36
        bool atEnd() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    37
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    38
        virtual qint64 read(char *data, qint64 maxlen);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    39
        virtual qint64 readLine(char *data, qint64 maxlen);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    40
        virtual qint64 write(const char *data, qint64 len);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    41
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    42
        bool isOpened() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    43
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    44
        QFile::FileError error() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    45
        QString errorString() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    46
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    47
        virtual bool supportsExtension(Extension extension) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    48
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    49
    private:
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    50
        PHYSFS_file *_handler;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    51
        qint64 _size;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    52
        FileFlags _flags;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    53
        QString _filename;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    54
        QDateTime _datetime;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    55
};
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    56
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    57
class FileEngineHandler : public QAbstractFileEngineHandler
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    58
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    59
    public:
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    60
        QAbstractFileEngine *create(const QString &filename) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    61
};
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    62
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    63
#endif