7768
|
1 |
#ifndef _FileEngine_h
|
|
2 |
#define _FileEngine_h
|
|
3 |
|
|
4 |
#include <QAbstractFileEngine>
|
|
5 |
#include <QAbstractFileEngineHandler>
|
7770
|
6 |
#include <QAbstractFileEngineIterator>
|
7768
|
7 |
#include <QDateTime>
|
|
8 |
|
|
9 |
#include "physfs.h"
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
class FileEngine : public QAbstractFileEngine
|
|
14 |
{
|
|
15 |
public:
|
|
16 |
FileEngine(const QString& filename);
|
|
17 |
|
|
18 |
virtual ~FileEngine();
|
|
19 |
|
|
20 |
virtual bool open(QIODevice::OpenMode openMode);
|
|
21 |
virtual bool close();
|
|
22 |
virtual bool flush();
|
|
23 |
virtual qint64 size() const;
|
|
24 |
virtual qint64 pos() const;
|
|
25 |
virtual bool seek(qint64 pos);
|
|
26 |
virtual bool isSequential() const;
|
|
27 |
virtual bool remove();
|
|
28 |
virtual bool mkdir(const QString &dirName, bool createParentDirectories) const;
|
|
29 |
virtual bool rmdir(const QString &dirName, bool recurseParentDirectories) const;
|
|
30 |
virtual bool caseSensitive() const;
|
|
31 |
virtual bool isRelativePath() const;
|
7770
|
32 |
QAbstractFileEngineIterator *beginEntryList(QDir::Filters filters, const QStringList & filterNames);
|
7768
|
33 |
virtual QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const;
|
|
34 |
virtual FileFlags fileFlags(FileFlags type=FileInfoAll) const;
|
|
35 |
virtual QString fileName(FileName file=DefaultName) const;
|
|
36 |
virtual QDateTime fileTime(FileTime time) const;
|
|
37 |
virtual void setFileName(const QString &file);
|
|
38 |
bool atEnd() const;
|
|
39 |
|
|
40 |
virtual qint64 read(char *data, qint64 maxlen);
|
|
41 |
virtual qint64 write(const char *data, qint64 len);
|
|
42 |
|
|
43 |
bool isOpened() const;
|
|
44 |
|
|
45 |
QFile::FileError error() const;
|
|
46 |
QString errorString() const;
|
|
47 |
|
|
48 |
virtual bool supportsExtension(Extension extension) const;
|
|
49 |
|
|
50 |
private:
|
|
51 |
PHYSFS_file *_handler;
|
|
52 |
qint64 _size;
|
|
53 |
FileFlags _flags;
|
|
54 |
QString _filename;
|
|
55 |
QDateTime _datetime;
|
|
56 |
};
|
|
57 |
|
|
58 |
class FileEngineHandler : public QAbstractFileEngineHandler
|
|
59 |
{
|
|
60 |
public:
|
7770
|
61 |
FileEngineHandler(char * argv0);
|
|
62 |
~FileEngineHandler();
|
|
63 |
|
7768
|
64 |
QAbstractFileEngine *create(const QString &filename) const;
|
7770
|
65 |
|
|
66 |
void mount(const QString & path);
|
7955
|
67 |
void mount(const QString & path, const QString & mountPoint);
|
7770
|
68 |
void setWriteDir(const QString & path);
|
|
69 |
|
|
70 |
// private:
|
|
71 |
static const QString scheme;
|
|
72 |
};
|
|
73 |
|
|
74 |
class FileEngineIterator : public QAbstractFileEngineIterator
|
|
75 |
{
|
|
76 |
public:
|
|
77 |
FileEngineIterator(QDir::Filters filters, const QStringList & nameFilters, const QStringList & entries);
|
|
78 |
|
|
79 |
bool hasNext() const;
|
|
80 |
QString next();
|
|
81 |
QString currentFileName() const;
|
|
82 |
private:
|
|
83 |
QStringList m_entries;
|
|
84 |
int m_index;
|
7768
|
85 |
};
|
|
86 |
|
|
87 |
#endif
|