Skip to content
API Documentation
BastionGuard™
Resource.hpp File Reference

Go to the source code of this file.

Macros

#define DATA_DIR   "/usr/share/BastionGuard/data"

Functions

std::string resource (const std::string &rel)

Macro Definition Documentation

◆ DATA_DIR

Function Documentation

◆ resource()

std::string resource ( const std::string & rel)
inline

Definition at line 31 of file Resource.hpp.

31 {
32 namespace fs = std::filesystem;
33
34 if (const char* env = std::getenv("BastionGuard_DATA")) {
35 std::string p = std::string(env) + "/" + rel;
36 if (fs::exists(p))
37 return p;
38 }
39
40
41 {
42 std::string system_path = std::string(DATA_DIR) + "/" + rel;
43 if (fs::exists(system_path))
44 return system_path;
45 }
46
47 {
48 std::string userBase;
49 if (const char* xdg = std::getenv("XDG_DATA_HOME"); xdg && *xdg) {
50 userBase = xdg;
51 } else if (const char* home = std::getenv("HOME"); home) {
52 userBase = std::string(home) + "/.local/share";
53 }
54
55 if (!userBase.empty()) {
56 std::string user_path = userBase + "/BastionGuard/data/" + rel;
57 if (fs::exists(user_path))
58 return user_path;
59 }
60 }
61
62 std::cerr << "⚠ Risorsa non trovata: " << rel << std::endl;
63
64 return std::string(DATA_DIR) + "/" + rel;
65}
#define DATA_DIR
Definition Resource.hpp:28

References DATA_DIR, and resource().

Referenced by AboutPage::AboutPage(), AlertWindow::AlertWindow(), AlertWindowRealtime::AlertWindowRealtime(), AntiPhishingEngine::AntiPhishingEngine(), MainWindow::apply_theme(), Backend::Backend(), BankGuiWindow::BankGuiWindow(), MainWindow::build_about_page(), BankGuiWindow::build_headerbar(), BastionGuard::wizard::WizardWindow::build_headerbar(), FirstRunServicesWindow::build_headerbar(), MainWindow::build_headerbar(), SecureGuiWindow::build_headerbar(), SettingsWindow::build_headerbar(), MainWindow::build_sidebar(), MainWindow::build_sidebar(), SettingsWindow::build_sidebar(), FirstRunServicesWindow::build_ui(), USBScanPage::build_usb_card(), AboutPage::buildContent(), AlertDialog::buildHeaderBar(), LanguageDialog::buildHeaderBar(), MainWindow::buildHeaderBar(), MainWindow::buildSidebar(), DashboardPage::DashboardPage(), DonatePage::DonatePage(), FirewallChoiceDialog::FirewallChoiceDialog(), LiveScanDialog::LiveScanDialog(), load_allowlist(), load_config(), AlertApp::load_css(), anonymous_namespace{main_window.cpp}::load_license_text(), load_samba_dirs(), AntiRansomEngine::load_yara_rules(), SettingsPage::loadPhishLists(), SettingsPage::loadScannerConfig(), MainWindow::loadTheme(), SambaPage::onAddDir(), SambaPage::onScanNow(), resource(), ScanPromptWindow::ScanPromptWindow(), SecureGuiWindow::SecureGuiWindow(), PrivacyPage::show_next_alert(), USBScanPage::show_scan_result(), ScanPage::showCloudPrivacyDisclaimer(), IdentityLeakPage::showLeakCheckDisclaimer(), IdentityLeakPage::showPrivacyPopup(), and BastionGuard::wizard::WizardWindow::worker_run().