AusweisApp
Lade ...
Suche ...
Keine Treffer
FileDestination.h
gehe zur Dokumentation dieser Datei
1
5#pragma once
6
7#include <QCoreApplication>
8#include <QDebug>
9#include <QFile>
10#include <QLibraryInfo>
11#include <QStandardPaths>
12#include <QStringBuilder>
13#include <QtGlobal>
14
15
16namespace governikus
17{
18
20{
21 Q_DISABLE_COPY(FileDestination)
22
23 private:
24 FileDestination() = delete;
25 ~FileDestination() = delete;
26
27 static QString getPath()
28 {
29#if defined(Q_OS_ANDROID)
30 return QStringLiteral("assets:");
31
32#elif defined(Q_OS_MACOS)
33 const auto& path = QCoreApplication::applicationDirPath() + QStringLiteral("/../Resources");
34
35 #if !defined(QT_NO_DEBUG)
36 if (!QFile::exists(path))
37 {
38 return QCoreApplication::applicationDirPath();
39 }
40 #endif
41
42 return path;
43
44#else
45 return QCoreApplication::applicationDirPath();
46
47#endif
48 }
49
50 public:
51 static QString getPath(const QString& pFilename,
52 QStandardPaths::LocateOption pOption = QStandardPaths::LocateFile,
53 QStandardPaths::StandardLocation pStandard = QStandardPaths::AppDataLocation)
54 {
55#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || (defined(Q_OS_BSD4) && !defined(Q_OS_MACOS) && !defined(Q_OS_IOS))
56#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
57 if (pFilename.compare(QStringLiteral("translations")) == 0)
58 {
59 return QLibraryInfo::location(QLibraryInfo::TranslationsPath);
60 }
61#endif
62
63 if (const auto& match = QStandardPaths::locate(pStandard, pFilename, pOption); !match.isNull())
64 {
65 return match;
66 }
67
68 qDebug() << pFilename << "not found in following destinations |" << pOption;
69 const auto defaultLocations = QStandardPaths::standardLocations(pStandard);
70 for (const auto& location : defaultLocations)
71 {
72 qDebug() << location;
73 }
74#else
75 Q_UNUSED(pOption)
76 Q_UNUSED(pStandard)
77#endif
78
79 return getPath() % QLatin1Char('/') % pFilename;
80 }
81
82
83};
84
85} // namespace governikus
Definition FileDestination.h:20
static QString getPath(const QString &pFilename, QStandardPaths::LocateOption pOption=QStandardPaths::LocateFile, QStandardPaths::StandardLocation pStandard=QStandardPaths::AppDataLocation)
Definition FileDestination.h:51
Defines the AccessRight and AccessRole enum.
Definition CommandApdu.h:17