X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=android%2Fassetreader.cpp;h=05160d6e41ea609d21b83444a31a1336c94322d7;hp=bf76704a8b873f724f526ab773e62c4a46562f7b;hb=db1aabc15dc8680673b943c2dd0f38a83c32a1d9;hpb=dddff2e7c658aa84f67186ade0a4845b5fb0b43f diff --git a/android/assetreader.cpp b/android/assetreader.cpp index bf76704a..05160d6e 100644 --- a/android/assetreader.cpp +++ b/android/assetreader.cpp @@ -22,17 +22,22 @@ #include #include #include +#include using namespace pv; -AndroidAssetReader::~AndroidAssetReader() -{} +using std::string; +using std::unique_ptr; -void AndroidAssetReader::open(struct sr_resource *res, std::string name) +void AndroidAssetReader::open(struct sr_resource *res, string name) { if (res->type == SR_RESOURCE_FIRMWARE) { - const auto path = QString::fromStdString("assets:/sigrok-firmware/" + name); - std::unique_ptr file {new QFile{path}}; + auto path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QString::fromStdString("sigrok-firmware/" + name)); + if (path.isEmpty()) + path = QString::fromStdString("assets:/sigrok-firmware/" + name); + + unique_ptr file {new QFile{path}}; if (!file->open(QIODevice::ReadOnly)) throw sigrok::Error{SR_ERR}; @@ -55,7 +60,7 @@ void AndroidAssetReader::close(struct sr_resource *res) qCritical("AndroidAssetReader: Invalid handle"); throw sigrok::Error{SR_ERR_ARG}; } - const std::unique_ptr file {static_cast(res->handle)}; + const unique_ptr file {static_cast(res->handle)}; res->handle = nullptr; file->close();