From 517aa353caaa6484a2607d93265c4aafc14997ae Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 1 Feb 2021 01:55:06 -0800 Subject: [PATCH] Qt: Add creating a VFileDevice from a QByteArray --- src/platform/qt/VFileDevice.cpp | 7 +++++++ src/platform/qt/VFileDevice.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/platform/qt/VFileDevice.cpp b/src/platform/qt/VFileDevice.cpp index c2eff887c..bce0ed830 100644 --- a/src/platform/qt/VFileDevice.cpp +++ b/src/platform/qt/VFileDevice.cpp @@ -91,6 +91,13 @@ VFileDevice::VFileDevice(const QString& filename, QIODevice::OpenMode mode, QObj } } +VFileDevice::VFileDevice(const QByteArray& mem, QObject* parent) + : QIODevice(parent) + , m_vf(VFileMemChunk(mem.constData(), mem.size())) +{ + setOpenMode(QIODevice::ReadWrite); +} + VFileDevice::~VFileDevice() { close(); } diff --git a/src/platform/qt/VFileDevice.h b/src/platform/qt/VFileDevice.h index b230d14ae..9df1aff93 100644 --- a/src/platform/qt/VFileDevice.h +++ b/src/platform/qt/VFileDevice.h @@ -19,6 +19,7 @@ Q_OBJECT public: VFileDevice(VFile* vf = nullptr, QObject* parent = nullptr); + VFileDevice(const QByteArray& mem, QObject* parent = nullptr); VFileDevice(const QString&, QIODevice::OpenMode, QObject* parent = nullptr); virtual ~VFileDevice();