23 {
24 namespace fs = std::filesystem;
25
26 if (const char* env = std::getenv("BSC_DATA")) {
27 std::string p = std::string(env) + "/" + rel;
28 if (fs::exists(p)) return p;
29 }
30
31 {
32 std::string system_path = std::string(
DATA_DIR) +
"/" + rel;
33 if (fs::exists(system_path)) return system_path;
34 }
35
36 {
37 std::string userBase;
38 if (const char* xdg = std::getenv("XDG_DATA_HOME"); xdg && *xdg)
39 userBase = xdg;
40 else if (const char* home = std::getenv("HOME"); home)
41 userBase = std::string(home) + "/.local/share";
42
43 if (!userBase.empty()) {
44 std::string user_path = userBase + "/bastionguard-sc/data/" + rel;
45 if (fs::exists(user_path)) return user_path;
46 }
47 }
48
49 std::cerr << "⚠ Risorsa non trovata: " << rel << std::endl;
50 return std::string(
DATA_DIR) +
"/" + rel;
51}