all repos — mgba @ 87313041c0fe8c6ea6531962aa14ea3668567c56

mGBA Game Boy Advance Emulator

Qt: Unified VFile opening interface
Jeffrey Pfau jeffrey@endrift.com
Fri, 29 May 2015 00:16:42 -0700
commit

87313041c0fe8c6ea6531962aa14ea3668567c56

parent

3c65ac986e8d2bbf64e1f55371c03f06e0342ce7

M src/platform/qt/CheatsModel.cppsrc/platform/qt/CheatsModel.cpp

@@ -5,12 +5,13 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this

* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "CheatsModel.h" +#include "VFileDevice.h" + #include <QFont> #include <QSet> extern "C" { #include "gba/cheats.h" -#include "util/vfs.h" } using namespace QGBA;

@@ -201,7 +202,7 @@ endInsertRows();

} void CheatsModel::loadFile(const QString& path) { - VFile* vf = VFileOpen(path.toLocal8Bit().constData(), O_RDONLY); + VFile* vf = VFileDevice::open(path, O_RDONLY); if (!vf) { return; }

@@ -212,7 +213,7 @@ vf->close(vf);

} void CheatsModel::saveFile(const QString& path) { - VFile* vf = VFileOpen(path.toLocal8Bit().constData(), O_TRUNC | O_CREAT | O_WRONLY); + VFile* vf = VFileDevice::open(path, O_TRUNC | O_CREAT | O_WRONLY); if (!vf) { return; }
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -8,6 +8,7 @@

#include "AudioProcessor.h" #include "InputController.h" #include "MultiplayerController.h" +#include "VFileDevice.h" #include <QDateTime> #include <QThread>

@@ -280,13 +281,13 @@ #endif

} if (!m_bios.isNull() &&m_useBios) { - m_threadContext.bios = VFileOpen(m_bios.toLocal8Bit().constData(), O_RDONLY); + m_threadContext.bios = VFileDevice::open(m_bios, O_RDONLY); } else { m_threadContext.bios = nullptr; } if (!m_patch.isNull()) { - m_threadContext.patch = VFileOpen(m_patch.toLocal8Bit().constData(), O_RDONLY); + m_threadContext.patch = VFileDevice::open(m_patch, O_RDONLY); } m_inputController->recalibrateAxes();

@@ -322,7 +323,7 @@ void GameController::importSharkport(const QString& path) {

if (!m_gameOpen) { return; } - VFile* vf = VFileOpen(path.toLocal8Bit().constData(), O_RDONLY); + VFile* vf = VFileDevice::open(path, O_RDONLY); if (!vf) { return; }

@@ -336,7 +337,7 @@ void GameController::exportSharkport(const QString& path) {

if (!m_gameOpen) { return; } - VFile* vf = VFileOpen(path.toLocal8Bit().constData(), O_WRONLY | O_CREAT | O_TRUNC); + VFile* vf = VFileDevice::open(path, O_WRONLY | O_CREAT | O_TRUNC); if (!vf) { return; }
M src/platform/qt/PaletteView.cppsrc/platform/qt/PaletteView.cpp

@@ -5,6 +5,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this

* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "PaletteView.h" +#include "VFileDevice.h" + #include <QFileDialog> #include <QFontDatabase>

@@ -86,7 +88,7 @@ if (filename.isNull()) {

m_controller->threadContinue(); return; } - VFile* vf = VFileOpen(filename.toLocal8Bit().constData(), O_WRONLY | O_CREAT | O_TRUNC); + VFile* vf = VFileDevice::open(filename, O_WRONLY | O_CREAT | O_TRUNC); if (!vf) { m_controller->threadContinue(); return;
M src/platform/qt/VFileDevice.cppsrc/platform/qt/VFileDevice.cpp

@@ -5,10 +5,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this

* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "VFileDevice.h" -extern "C" { -#include "util/vfs.h" -} - using namespace QGBA; VFileDevice::VFileDevice(VFile* vf, QObject* parent)

@@ -29,3 +25,7 @@

qint64 VFileDevice::size() const { return m_vf->size(m_vf); } + +VFile* VFileDevice::open(QString path, int mode) { + return VFileOpen(path.toLocal8Bit().constData(), mode); +}
M src/platform/qt/VFileDevice.hsrc/platform/qt/VFileDevice.h

@@ -8,7 +8,9 @@ #define QGBA_VFILE_DEVICE

#include <QFileDevice> -struct VFile; +extern "C" { +#include "util/vfs.h" +} namespace QGBA {

@@ -17,6 +19,8 @@ Q_OBJECT

public: VFileDevice(VFile* vf, QObject* parent = nullptr); + + static VFile* open(QString path, int mode); protected: virtual qint64 readData(char* data, qint64 maxSize) override;