all repos — mgba @ 0ef07f7c26d440aa216925b1d6ad4886fa3fde50

mGBA Game Boy Advance Emulator

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

 1#include "VFileDevice.h"
 2
 3extern "C" {
 4#include "util/vfs.h"
 5}
 6
 7using namespace QGBA;
 8
 9VFileDevice::VFileDevice(VFile* vf, QObject* parent)
10	: QIODevice(parent)
11	, m_vf(vf)
12{
13	// Nothing to do
14}
15
16qint64 VFileDevice::readData(char* data, qint64 maxSize) {
17	return m_vf->read(m_vf, data, maxSize);
18}
19
20qint64 VFileDevice::writeData(const char* data, qint64 maxSize) {
21	return m_vf->write(m_vf, data, maxSize);
22}
23
24qint64 VFileDevice::size() const {
25	// TODO: Add size method to VFile so this can be actually const
26	ssize_t pos = m_vf->seek(m_vf, 0, SEEK_CUR);
27	qint64 size = m_vf->seek(m_vf, 0, SEEK_END);
28	m_vf->seek(m_vf, pos, SEEK_SET);
29	return size;
30}