Qt: Add VFileDevice from filename API
Vicki Pfau vi@endrift.com
Tue, 25 Aug 2020 20:21:58 -0700
2 files changed,
18 insertions(+),
0 deletions(-)
M
src/platform/qt/VFileDevice.cpp
→
src/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.h
→
src/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;