QTfrontend/util/FileEngine.h
author Mitchell Kember <mk12360@gmail.com>
Fri, 30 Nov 2012 15:29:09 -0500
changeset 8147 53190e590919
parent 8115 ac1007c6dea8
child 8178 8bd087478b48
permissions -rw-r--r--
Use same macro for hiding video record button and keybinding Modified my previous patch to use the already-in-place VIDEOREC macro (used previously just for hiding the button on the main menu) instead of creating another one. https://google-melange.appspot.com/gci/task/view/google/gci2012/7948213
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>
7770
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
     6
#include <QAbstractFileEngineIterator>
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     7
#include <QDateTime>
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     8
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
     9
#include "physfs.h"
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
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    13
class FileEngine : public QAbstractFileEngine
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    14
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    15
    public:
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    16
        FileEngine(const QString& filename);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    17
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    18
        virtual ~FileEngine();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    19
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    20
        virtual bool open(QIODevice::OpenMode openMode);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    21
        virtual bool close();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    22
        virtual bool flush();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    23
        virtual qint64 size() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    24
        virtual qint64 pos() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    25
        virtual bool seek(qint64 pos);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    26
        virtual bool isSequential() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    27
        virtual bool remove();
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    28
        virtual bool mkdir(const QString &dirName, bool createParentDirectories) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    29
        virtual bool rmdir(const QString &dirName, bool recurseParentDirectories) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    30
        virtual bool caseSensitive() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    31
        virtual bool isRelativePath() const;
7770
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    32
        QAbstractFileEngineIterator *beginEntryList(QDir::Filters filters, const QStringList & filterNames);
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    33
        virtual QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    34
        virtual FileFlags fileFlags(FileFlags type=FileInfoAll) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    35
        virtual QString fileName(FileName file=DefaultName) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    36
        virtual QDateTime fileTime(FileTime time) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    37
        virtual void setFileName(const QString &file);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    38
        bool atEnd() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    39
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    40
        virtual qint64 read(char *data, qint64 maxlen);
8112
d85dc8a8f41c Implement QAbstractFileEngine::FastReadLineExtension
unc0rr
parents: 8055
diff changeset
    41
        virtual qint64 readLine(char *data, qint64 maxlen);
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    42
        virtual qint64 write(const char *data, qint64 len);
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    43
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    44
        bool isOpened() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    45
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    46
        QFile::FileError error() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    47
        QString errorString() const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    48
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    49
        virtual bool supportsExtension(Extension extension) const;
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    50
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    51
    private:
8115
ac1007c6dea8 Refactor identifiers names
unc0rr
parents: 8112
diff changeset
    52
        PHYSFS_file *m_handle;
ac1007c6dea8 Refactor identifiers names
unc0rr
parents: 8112
diff changeset
    53
        qint64 m_size;
ac1007c6dea8 Refactor identifiers names
unc0rr
parents: 8112
diff changeset
    54
        FileFlags m_flags;
ac1007c6dea8 Refactor identifiers names
unc0rr
parents: 8112
diff changeset
    55
        QString m_fileName;
ac1007c6dea8 Refactor identifiers names
unc0rr
parents: 8112
diff changeset
    56
        QDateTime m_date;
8112
d85dc8a8f41c Implement QAbstractFileEngine::FastReadLineExtension
unc0rr
parents: 8055
diff changeset
    57
        bool m_bufferSet;
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    58
};
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    59
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    60
class FileEngineHandler : public QAbstractFileEngineHandler
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    61
{
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    62
    public:
7770
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    63
        FileEngineHandler(char * argv0);
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    64
        ~FileEngineHandler();
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    65
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    66
        QAbstractFileEngine *create(const QString &filename) const;
7770
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    67
8055
04dd8b7fb605 - Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents: 8052
diff changeset
    68
        static void mount(const QString & path);
04dd8b7fb605 - Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents: 8052
diff changeset
    69
        static void mount(const QString & path, const QString & mountPoint);
04dd8b7fb605 - Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents: 8052
diff changeset
    70
        static void setWriteDir(const QString & path);
04dd8b7fb605 - Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents: 8052
diff changeset
    71
        static void mountPacks();
7770
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    72
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    73
//    private:
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    74
        static const QString scheme;
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    75
};
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    76
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    77
class FileEngineIterator : public QAbstractFileEngineIterator
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    78
{
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    79
public:
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    80
        FileEngineIterator(QDir::Filters filters, const QStringList & nameFilters, const QStringList & entries);
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    81
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    82
        bool hasNext() const;
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    83
        QString next();
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    84
        QString currentFileName() const;
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    85
private:
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    86
        QStringList m_entries;
ff3442338882 Many bugfixes and features to FileEngine
unc0rr
parents: 7768
diff changeset
    87
        int m_index;
7768
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    88
};
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    89
13e2037ebc79 Try using PhysicsFS.
unc0rr
parents:
diff changeset
    90
#endif