wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
InstallRelativePaths.cpp
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
5
6#include <QCoreApplication>
7#include <QDir>
8
9QStringList InstallRelativePaths::candidates(const QString &category)
10{
11 const QString appDir = QCoreApplication::applicationDirPath();
12
13 QStringList result = {
14 appDir + QLatin1Char('/') + category, // Windows / dev builds
15 };
16#ifdef Q_OS_MACOS
17 result << appDir + QStringLiteral("/../Resources/") + category; // macOS app bundle
18#endif
19#ifdef Q_OS_LINUX
20 result << qEnvironmentVariable("APPDIR") + QStringLiteral("/usr/share/wiredpanda/") + category; // AppImage
21 result << appDir + QStringLiteral("/../share/wiredpanda/") + category; // native FHS install (bin/ -> share/wiredpanda/<category>)
22#endif
23#ifdef Q_OS_WASM
24 result << QStringLiteral("/") + category; // WASM virtual filesystem
25#endif
26 result << category; // CWD fallback (development)
27
28 return result;
29}
30
31QString InstallRelativePaths::resolve(const QString &category)
32{
33 for (const QString &candidate : candidates(category)) {
34 if (!candidate.isEmpty() && QDir(candidate).exists()) {
35 return candidate;
36 }
37 }
38 return {};
39}
Per-platform resolution of install-relative content directories.
static QString resolve(const QString &category)
static QStringList candidates(const QString &category)