all repos — mgba @ 6c805acab6673dfdb19b5ff18661008d16be8c82

mGBA Game Boy Advance Emulator

Qt: Add VFileDevice from filename API
Vicki Pfau vi@endrift.com
Tue, 25 Aug 2020 20:21:58 -0700
commit

6c805acab6673dfdb19b5ff18661008d16be8c82

parent

fcda3df24dd346cb8637209dcb25e05a7adc25ec

2 files changed, 18 insertions(+), 0 deletions(-)

jump to
M src/platform/qt/VFileDevice.cppsrc/platform/qt/VFileDevice.cpp

@@ -19,6 +19,23 @@ setOpenMode(QIODevice::ReadWrite);

} } +VFileDevice::VFileDevice(const QString& filename, QIODevice::OpenMode mode, QObject* parent) + : QIODevice(parent) +{ + int posixMode = 0; + if ((mode & QIODevice::ReadWrite) == QIODevice::ReadWrite) { + posixMode = O_RDWR; + } else if (mode & QIODevice::ReadOnly) { + posixMode = O_RDONLY; + } else if (mode & QIODevice::WriteOnly) { + posixMode = O_WRONLY; + } + m_vf = open(filename, posixMode); + if (m_vf) { + setOpenMode(mode); + } +} + void VFileDevice::close() { if (!m_vf) { return;
M src/platform/qt/VFileDevice.hsrc/platform/qt/VFileDevice.h

@@ -17,6 +17,7 @@ Q_OBJECT

public: VFileDevice(VFile* vf = nullptr, QObject* parent = nullptr); + VFileDevice(const QString&, QIODevice::OpenMode, QObject* parent = nullptr); virtual void close() override; virtual bool seek(qint64 pos) override;