-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAbstractFileSystem.h
45 lines (37 loc) · 1.34 KB
/
AbstractFileSystem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef IFILESYSTEMH
#define IFILESYSTEMH
#include <QByteArray>
#include <QString>
#include <QIODevice>
#include <QTextStream>
#include <QStringList>
#include "IFileRequester.h"
namespace TilesEditor
{
class AbstractFileSystem
{
public:
QString readAllToString(const QString& name) {
auto stream = openStream(name, QIODevice::ReadOnly);
if (stream != nullptr)
{
QTextStream textStream(stream);
QString retval = textStream.readAll();
delete stream;
return retval;
}
return "";
}
//Filename should be name part only. not FULL PATH
virtual void requestFile(IFileRequester* requester, const QString& fileName) = 0;
virtual void removeListener(IFileRequester* requester) = 0;
virtual QStringList getFolders(const QString& parent) = 0;
virtual bool fileExists(const QString& fileName) = 0;
virtual QIODevice* openStream(const QString& fileName, QIODeviceBase::OpenModeFlag mode) = 0;
virtual QString getOpenFileName(const QString& caption, const QString& dir, const QString& filter) = 0;
virtual QString getSaveFileName(const QString& caption, const QString& dir, const QString& filter) = 0;
//this is called when a file has finished being written to. also delete the stream object in this function
virtual void endWrite(IFileRequester* requester, const QString& fileName, QIODevice* stream) = 0;
};
}
#endif