24 #include <QtCore/QDebug> 25 #include <QtCore/QFile> 26 #include <QtCore/QStandardPaths> 28 #include <libsigrok/libsigrok.h> 33 using std::unique_ptr;
37 if (res->type == SR_RESOURCE_FIRMWARE) {
38 auto path = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
39 QString::fromStdString(
"sigrok-firmware/" + name));
41 path = QString::fromStdString(
"assets:/sigrok-firmware/" + name);
43 unique_ptr<QFile>
file {
new QFile{path}};
45 if (!
file->open(QIODevice::ReadOnly))
46 throw sigrok::Error{SR_ERR};
48 const auto size =
file->size();
50 throw sigrok::Error{SR_ERR};
53 res->handle =
file.release();
55 qWarning() <<
"AndroidAssetReader: Unknown resource type" << res->type;
56 throw sigrok::Error{SR_ERR};
63 qCritical(
"AndroidAssetReader: Invalid handle");
64 throw sigrok::Error{SR_ERR_ARG};
66 const unique_ptr<QFile>
file {
static_cast<QFile*
>(res->handle)};
67 res->handle =
nullptr;
75 qCritical(
"AndroidAssetReader: Invalid handle");
76 throw sigrok::Error{SR_ERR_ARG};
78 auto *
const file =
static_cast<QFile*
>(res->handle);
80 const auto n_read =
file->read(static_cast<char*>(buf), count);
82 throw sigrok::Error{SR_ERR};
void open(struct sr_resource *res, string name) override
size_t read(const struct sr_resource *res, void *buf, size_t count) override
libsigrok allows users to import and export data from files in various formats some of them as generic as others very specific For a list and make sure to check not so common and outright exotic ways to represent data and sigrok tries to suit as many needs as it can To see which formats your version of PulseView just click on the small arrow next to the _Open_ PulseView will ask for the file name to open Once you picked the file
void close(struct sr_resource *res) override