10017
|
1 |
#ifndef _FileEngine_h
|
|
2 |
#define _FileEngine_h
|
|
3 |
|
|
4 |
#include <QAbstractFileEngine>
|
|
5 |
#include <QAbstractFileEngineHandler>
|
|
6 |
#include <QAbstractFileEngineIterator>
|
|
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 setSize(qint64 size);
|
|
26 |
virtual bool seek(qint64 pos);
|
|
27 |
virtual bool isSequential() const;
|
|
28 |
virtual bool remove();
|
|
29 |
virtual bool mkdir(const QString &dirName, bool createParentDirectories) const;
|
|
30 |
virtual bool rmdir(const QString &dirName, bool recurseParentDirectories) const;
|
|
31 |
virtual bool caseSensitive() const;
|
|
32 |
virtual bool isRelativePath() const;
|
|
33 |
QAbstractFileEngineIterator *beginEntryList(QDir::Filters filters, const QStringList & filterNames);
|
|
34 |
virtual QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const;
|
|
35 |
virtual FileFlags fileFlags(FileFlags type=FileInfoAll) const;
|
|
36 |
virtual QString fileName(FileName file=DefaultName) const;
|
|
37 |
virtual QDateTime fileTime(FileTime time) const;
|
|
38 |
virtual void setFileName(const QString &file);
|
|
39 |
bool atEnd() const;
|
|
40 |
|
|
41 |
virtual qint64 read(char *data, qint64 maxlen);
|
|
42 |
virtual qint64 readLine(char *data, qint64 maxlen);
|
|
43 |
virtual qint64 write(const char *data, qint64 len);
|
|
44 |
|
|
45 |
bool isOpened() const;
|
|
46 |
|
|
47 |
QFile::FileError error() const;
|
|
48 |
QString errorString() const;
|
|
49 |
|
|
50 |
virtual bool supportsExtension(Extension extension) const;
|
|
51 |
|
|
52 |
private:
|
|
53 |
PHYSFS_file *m_handle;
|
|
54 |
qint64 m_size;
|
|
55 |
FileFlags m_flags;
|
|
56 |
QString m_fileName;
|
|
57 |
QDateTime m_date;
|
|
58 |
bool m_bufferSet;
|
|
59 |
bool m_readWrite;
|
|
60 |
};
|
|
61 |
|
|
62 |
class FileEngineHandler : public QAbstractFileEngineHandler
|
|
63 |
{
|
|
64 |
public:
|
|
65 |
FileEngineHandler(char * argv0);
|
|
66 |
~FileEngineHandler();
|
|
67 |
|
|
68 |
QAbstractFileEngine *create(const QString &filename) const;
|
|
69 |
|
|
70 |
static void mount(const QString & path);
|
|
71 |
static void mount(const QString & path, const QString & mountPoint);
|
|
72 |
static void setWriteDir(const QString & path);
|
|
73 |
static void mountPacks();
|
|
74 |
static QString errorStr();
|
|
75 |
|
|
76 |
// private:
|
|
77 |
static const QString scheme;
|
|
78 |
};
|
|
79 |
|
|
80 |
class FileEngineIterator : public QAbstractFileEngineIterator
|
|
81 |
{
|
|
82 |
public:
|
|
83 |
FileEngineIterator(QDir::Filters filters, const QStringList & nameFilters, const QStringList & entries);
|
|
84 |
|
|
85 |
bool hasNext() const;
|
|
86 |
QString next();
|
|
87 |
QString currentFileName() const;
|
|
88 |
private:
|
|
89 |
QStringList m_entries;
|
|
90 |
int m_index;
|
|
91 |
};
|
|
92 |
|
|
93 |
#endif
|