| 124 | } |
| 125 | |
| 126 | File hostExecutable() { |
| 127 | #if VISAGE_WINDOWS |
| 128 | static File path; |
| 129 | if (path.empty()) { |
| 130 | char buffer[MAX_PATH]; |
| 131 | GetModuleFileNameA(nullptr, buffer, MAX_PATH); |
| 132 | path = buffer; |
| 133 | } |
| 134 | return path; |
| 135 | #elif VISAGE_MAC |
| 136 | static constexpr int kMaxPathLength = 1 << 14; |
| 137 | char path[kMaxPathLength]; |
| 138 | uint32_t size = kMaxPathLength - 1; |
| 139 | if (_NSGetExecutablePath(path, &size)) |
| 140 | return {}; |
| 141 | |
| 142 | path[size] = '\0'; |
| 143 | return std::filesystem::canonical(path); |
| 144 | #else |
| 145 | static constexpr int kMaxPathLength = 1 << 14; |
| 146 | char path[kMaxPathLength]; |
| 147 | ssize_t size = readlink("/proc/self/exe", path, kMaxPathLength - 1); |
| 148 | if (size < 0) |
| 149 | return {}; |
| 150 | |
| 151 | path[size] = '\0'; |
| 152 | return std::filesystem::canonical(path); |
| 153 | #endif |
| 154 | } |
| 155 | |
| 156 | File appDataDirectory() { |
| 157 | #if VISAGE_WINDOWS |
no outgoing calls
no test coverage detected