mirror of https://github.com/mgba-emu/mgba.git
Qt: Add VFileDevice from filename API
This commit is contained in:
parent
fcda3df24d
commit
6c805acab6
|
@ -19,6 +19,23 @@ VFileDevice::VFileDevice(VFile* vf, QObject* parent)
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue