| 52 | } |
| 53 | |
| 54 | void cResourceMan::addDefaultDirs() { |
| 55 | std::string path; |
| 56 | |
| 57 | // Working Dir |
| 58 | mAllPaths.push_back(getcwd()); |
| 59 | |
| 60 | #ifdef WIN32 |
| 61 | size_t a = 512; |
| 62 | char path1[512]; |
| 63 | getenv_s(&a, path1, "USERPROFILE"); |
| 64 | path.append(path1, a - 1); |
| 65 | |
| 66 | if (path.size()) |
| 67 | addBaseDir(path + "/Documents/"); |
| 68 | #else |
| 69 | //Per-user data dir (Flatpak: ~/.var/app/<app-id>/data) |
| 70 | char* path1 = std::getenv("XDG_DATA_HOME"); |
| 71 | if (path1 && *path1) { |
| 72 | addBaseDir(std::string(path1) + "/"); |
| 73 | } |
| 74 | |
| 75 | //XDG_DATA_DIRS |
| 76 | path1 = std::getenv("XDG_DATA_DIRS"); |
| 77 | if (path1) { |
| 78 | std::stringstream ss; |
| 79 | ss << path1; |
| 80 | while (ss.good()) { |
| 81 | std::string substr; |
| 82 | std::getline(ss, substr, ':'); |
| 83 | addBaseDir(substr); |
| 84 | } |
| 85 | } |
| 86 | //HOME -> ~/.local/share |
| 87 | path1 = std::getenv("HOME"); |
| 88 | if (path1) { |
| 89 | path = path1; |
| 90 | addBaseDir(path + "/.local/share/"); |
| 91 | } |
| 92 | //Fallback to /usr/local/share |
| 93 | addBaseDir("/usr/local/share/"); |
| 94 | #endif |
| 95 | } |
| 96 | |
| 97 | void cResourceMan::validatePaths() { |
| 98 | |