]> sigrok.org Git - pulseview.git/blobdiff - android/assetreader.cpp
Don't use deprecated headers.
[pulseview.git] / android / assetreader.cpp
index bf76704a8b873f724f526ab773e62c4a46562f7b..d0af1678ed137ebf5c0303ff8c36e177ea279320 100644 (file)
 #include <memory>
 #include <QtCore/QDebug>
 #include <QtCore/QFile>
+#include <QtCore/QStandardPaths>
 
 using namespace pv;
 
+using std::string;
+using std::unique_ptr;
+
 AndroidAssetReader::~AndroidAssetReader()
 {}
 
-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<QFile> 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<QFile> file {new QFile{path}};
 
                if (!file->open(QIODevice::ReadOnly))
                        throw sigrok::Error{SR_ERR};
@@ -55,7 +63,7 @@ void AndroidAssetReader::close(struct sr_resource *res)
                qCritical("AndroidAssetReader: Invalid handle");
                throw sigrok::Error{SR_ERR_ARG};
        }
-       const std::unique_ptr<QFile> file {static_cast<QFile*>(res->handle)};
+       const unique_ptr<QFile> file {static_cast<QFile*>(res->handle)};
        res->handle = nullptr;
 
        file->close();