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);
|
|
67 |
void setWriteDir(const QString & path);
|
|
68 |
|
|
69 |
// private:
|
|
70 |
static const QString scheme;
|
|
71 |
};
|
|
72 |
|
|
73 |
class FileEngineIterator : public QAbstractFileEngineIterator
|
|
74 |
{
|
|
75 |
public:
|
|
76 |
FileEngineIterator(QDir::Filters filters, const QStringList & nameFilters, const QStringList & entries);
|
|
77 |
|
|
78 |
bool hasNext() const;
|
|
79 |
QString next();
|
|
80 |
QString currentFileName() const;
|
|
81 |
private:
|
|
82 |
QStringList m_entries;
|
|
83 |
int m_index;
|
7768
|
84 |
};
|
|
85 |
|
|
86 |
#endif
|