| 139 | } |
| 140 | |
| 141 | QString findLibrary(QString libName) |
| 142 | { |
| 143 | #ifdef __GLIBC__ |
| 144 | const char* library = libName.toLocal8Bit().constData(); |
| 145 | |
| 146 | void* handle = dlopen(library, RTLD_NOW); |
| 147 | if (!handle) { |
| 148 | qCritical() << "dlopen() failed:" << dlerror(); |
| 149 | return {}; |
| 150 | } |
| 151 | |
| 152 | char path[PATH_MAX]; |
| 153 | if (dlinfo(handle, RTLD_DI_ORIGIN, path) == -1) { |
| 154 | qCritical() << "dlinfo() failed:" << dlerror(); |
| 155 | dlclose(handle); |
| 156 | return {}; |
| 157 | } |
| 158 | |
| 159 | auto fullPath = FS::PathCombine(QString(path), libName); |
| 160 | |
| 161 | dlclose(handle); |
| 162 | return fullPath; |
| 163 | #else |
| 164 | qWarning() << "MangoHud::findLibrary is not implemented on this platform"; |
| 165 | return {}; |
| 166 | #endif |
| 167 | } |
| 168 | } // namespace MangoHud |
| 169 | |
| 170 | #ifdef UNDEF_GNU_SOURCE |
no test coverage detected