diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-09-28 22:50:12 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-09-28 22:50:12 +0300 |
commit | 9acbf98f940204cd141203a6eccbc9a7351e5a78 (patch) | |
tree | 6ac8fe4b0e51ee58c67e02783fe97b00de707167 /launcher/MangoHud.cpp | |
parent | 254444470f020b086648ac496ebfffb7d3e9ce05 (diff) | |
parent | 59e565ef96b85be9a25fa5d4f1723ee87fd5e75e (diff) | |
download | PrismLauncher-9acbf98f940204cd141203a6eccbc9a7351e5a78.tar.gz PrismLauncher-9acbf98f940204cd141203a6eccbc9a7351e5a78.tar.bz2 PrismLauncher-9acbf98f940204cd141203a6eccbc9a7351e5a78.zip |
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into feat/acknowledge_release_type
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/MangoHud.cpp')
-rw-r--r-- | launcher/MangoHud.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/launcher/MangoHud.cpp b/launcher/MangoHud.cpp index 5758da3a..ab79f418 100644 --- a/launcher/MangoHud.cpp +++ b/launcher/MangoHud.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ +#include <QDebug> #include <QDir> #include <QString> #include <QStringList> @@ -26,6 +27,15 @@ #include "Json.h" #include "MangoHud.h" +#ifdef __GLIBC__ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#define UNDEF_GNU_SOURCE +#endif +#include <dlfcn.h> +#include <linux/limits.h> +#endif + namespace MangoHud { QString getLibraryString() @@ -106,4 +116,37 @@ QString getLibraryString() return QString(); } + +QString findLibrary(QString libName) +{ +#ifdef __GLIBC__ + const char* library = libName.toLocal8Bit().constData(); + + void* handle = dlopen(library, RTLD_NOW); + if (!handle) { + qCritical() << "dlopen() failed:" << dlerror(); + return {}; + } + + char path[PATH_MAX]; + if (dlinfo(handle, RTLD_DI_ORIGIN, path) == -1) { + qCritical() << "dlinfo() failed:" << dlerror(); + dlclose(handle); + return {}; + } + + auto fullPath = FS::PathCombine(QString(path), libName); + + dlclose(handle); + return fullPath; +#else + qWarning() << "MangoHud::findLibrary is not implemented on this platform"; + return {}; +#endif +} } // namespace MangoHud + +#ifdef UNDEF_GNU_SOURCE +#undef _GNU_SOURCE +#undef UNDEF_GNU_SOURCE +#endif |