AusweisApp
Lade ...
Suche ...
Keine Treffer
FileDestination.h
gehe zur Dokumentation dieser Datei
1
5/*
6 * \brief Little helper that will abstract pathes of underlying systems
7 */
8
9#pragma once
10
11#include <QCoreApplication>
12#include <QDebug>
13#include <QFile>
14#include <QLibraryInfo>
15#include <QStandardPaths>
16#include <QStringBuilder>
17#include <QtGlobal>
18
19namespace governikus
20{
21
23{
25
26 private:
27 FileDestination() = delete;
28 ~FileDestination() = delete;
29
30 static QString getPath()
31 {
32#if defined(Q_OS_ANDROID)
33 return QStringLiteral("assets:");
34
35#elif defined(Q_OS_MACOS)
36 const auto& path = QCoreApplication::applicationDirPath() + QStringLiteral("/../Resources");
37
38 #if !defined(QT_NO_DEBUG)
39 if (!QFile::exists(path))
40 {
41 return QCoreApplication::applicationDirPath();
42 }
43 #endif
44
45 return path;
46
47#else
48 return QCoreApplication::applicationDirPath();
49
50#endif
51 }
52
53 public:
54 static QString getPath(const QString& pFilename,
55 QStandardPaths::LocateOption pOption = QStandardPaths::LocateFile,
56 QStandardPaths::StandardLocation pStandard = QStandardPaths::AppDataLocation)
57 {
58#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || (defined(Q_OS_BSD4) && !defined(Q_OS_MACOS) && !defined(Q_OS_IOS))
59#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
60 if (pFilename.compare(QStringLiteral("translations")) == 0)
61 {
62 return QLibraryInfo::location(QLibraryInfo::TranslationsPath);
63 }
64#endif
65
66 if (const auto& match = QStandardPaths::locate(pStandard, pFilename, pOption); !match.isNull())
67 {
68 return match;
69 }
70
71 qDebug() << pFilename << "not found in following destinations |" << pOption;
72 const auto defaultLocations = QStandardPaths::standardLocations(pStandard);
73 for (const auto& location : defaultLocations)
74 {
75 qDebug() << location;
76 }
77#else
80#endif
81
82 return getPath() % QLatin1Char('/') % pFilename;
83 }
84
85
86};
87
88} // namespace governikus
Definition FileDestination.h:23
static QString getPath(const QString &pFilename, QStandardPaths::LocateOption pOption=QStandardPaths::LocateFile, QStandardPaths::StandardLocation pStandard=QStandardPaths::AppDataLocation)
Definition FileDestination.h:54
Implementation of GeneralAuthenticate response APDUs.
Definition CommandApdu.h:17
QSharedPointer< T > decodeObject(const QByteArray &pData, bool pLogging=true)
Template function for decoding an OpenSSL type from DER encoded QByteArray.
Definition ASN1TemplateUtil.h:114