author | nemo |
Sun, 27 Oct 2013 22:34:25 -0400 | |
changeset 9583 | 37a6d807c140 |
parent 9170 | 7c75643d0b66 |
child 10017 | de822cd3df3a |
permissions | -rw-r--r-- |
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; |
|
8178 | 25 |
virtual bool setSize(qint64 size); |
7768 | 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; |
|
7770 | 33 |
QAbstractFileEngineIterator *beginEntryList(QDir::Filters filters, const QStringList & filterNames); |
7768 | 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); |
|
8112
d85dc8a8f41c
Implement QAbstractFileEngine::FastReadLineExtension
unc0rr
parents:
8055
diff
changeset
|
42 |
virtual qint64 readLine(char *data, qint64 maxlen); |
7768 | 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: |
|
8115 | 53 |
PHYSFS_file *m_handle; |
54 |
qint64 m_size; |
|
55 |
FileFlags m_flags; |
|
56 |
QString m_fileName; |
|
57 |
QDateTime m_date; |
|
8112
d85dc8a8f41c
Implement QAbstractFileEngine::FastReadLineExtension
unc0rr
parents:
8055
diff
changeset
|
58 |
bool m_bufferSet; |
8178 | 59 |
bool m_readWrite; |
7768 | 60 |
}; |
61 |
||
62 |
class FileEngineHandler : public QAbstractFileEngineHandler |
|
63 |
{ |
|
64 |
public: |
|
7770 | 65 |
FileEngineHandler(char * argv0); |
66 |
~FileEngineHandler(); |
|
67 |
||
7768 | 68 |
QAbstractFileEngine *create(const QString &filename) const; |
7770 | 69 |
|
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
|
70 |
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
|
71 |
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
|
72 |
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
|
73 |
static void mountPacks(); |
9170 | 74 |
static QString errorStr(); |
7770 | 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; |
|
7768 | 91 |
}; |
92 |
||
93 |
#endif |