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#pragma once
7
8#include <QFileDevice>
9
10struct VDir;
11struct VFile;
12
13namespace QGBA {
14
15class VFileDevice : public QIODevice {
16Q_OBJECT
17
18public:
19 VFileDevice(VFile* vf = nullptr, QObject* parent = nullptr);
20
21 virtual void close() override;
22 virtual bool seek(qint64 pos) override;
23 virtual qint64 size() const override;
24
25 bool resize(qint64 sz);
26
27 VFileDevice& operator=(VFile*);
28 operator VFile*() { return m_vf; }
29
30 static VFile* open(const QString& path, int mode);
31 static VDir* openDir(const QString& path);
32 static VDir* openArchive(const QString& path);
33
34protected:
35 virtual qint64 readData(char* data, qint64 maxSize) override;
36 virtual qint64 writeData(const char* data, qint64 maxSize) override;
37
38private:
39 VFile* m_vf;
40};
41
42}