all repos — mgba @ 48cf8448c161b51f49d7ee0aa87303c329487d57

mGBA Game Boy Advance Emulator

src/platform/qt/VFileDevice.h (view raw)

 1/* Copyright (c) 2013-2014 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef QGBA_VFILE_DEVICE
 7#define QGBA_VFILE_DEVICE
 8
 9#include <QFileDevice>
10
11struct VDir;
12struct VFile;
13
14namespace QGBA {
15
16class VFileDevice : public QIODevice {
17Q_OBJECT
18
19public:
20	VFileDevice(VFile* vf = nullptr, QObject* parent = nullptr);
21
22	virtual void close() override;
23	virtual bool seek(qint64 pos) override;
24	virtual qint64 size() const override;
25
26	bool resize(qint64 sz);
27
28	VFileDevice& operator=(VFile*);
29	operator VFile*() { return m_vf; }
30
31	static VFile* open(const QString& path, int mode);
32	static VDir* openDir(const QString& path);
33	static VDir* openArchive(const QString& path);
34
35protected:
36	virtual qint64 readData(char* data, qint64 maxSize) override;
37	virtual qint64 writeData(const char* data, qint64 maxSize) override;
38
39private:
40	VFile* m_vf;
41};
42
43}
44
45#endif